test: green up after Phase 2 merge for #26\n\n- Fix AST tests (is_override)\n- Align MIR builder test with current If AST\n- Adjust ResultBox API usage in tests\n- Add len() helpers to ArrayBox/BufferBox for tests
This commit is contained in:
@ -928,6 +928,7 @@ mod tests {
|
||||
}
|
||||
],
|
||||
is_static: false, // 通常のメソッド
|
||||
is_override: false,
|
||||
span: Span::unknown(),
|
||||
});
|
||||
|
||||
@ -983,4 +984,4 @@ mod tests {
|
||||
assert!(binary_op.is_expression());
|
||||
assert!(binary_op.info().contains("+"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,11 @@ impl ArrayBox {
|
||||
pub fn length(&self) -> Box<dyn NyashBox> {
|
||||
Box::new(IntegerBox::new(self.items.lock().unwrap().len() as i64))
|
||||
}
|
||||
|
||||
/// Rust向けヘルパー: 要素数をusizeで取得(テスト用)
|
||||
pub fn len(&self) -> usize {
|
||||
self.items.lock().unwrap().len()
|
||||
}
|
||||
|
||||
/// インデックスで要素を取得
|
||||
pub fn get(&self, index: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
|
||||
@ -302,4 +307,4 @@ impl NyashBox for ArrayBox {
|
||||
BoolBox::new(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,11 @@ impl BufferBox {
|
||||
base: BoxBase::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Rust向けヘルパー: バッファ長をusizeで取得(テスト用)
|
||||
pub fn len(&self) -> usize {
|
||||
self.data.lock().unwrap().len()
|
||||
}
|
||||
|
||||
pub fn from_vec(data: Vec<u8>) -> Self {
|
||||
BufferBox {
|
||||
|
||||
@ -469,19 +469,20 @@ mod tests {
|
||||
fn test_if_statement_building() {
|
||||
let mut builder = MirBuilder::new();
|
||||
|
||||
let ast = ASTNode::IfStatement {
|
||||
// Adapt test to current AST: If with statement bodies
|
||||
let ast = ASTNode::If {
|
||||
condition: Box::new(ASTNode::Literal {
|
||||
value: LiteralValue::Boolean(true),
|
||||
value: LiteralValue::Bool(true),
|
||||
span: Span::unknown(),
|
||||
}),
|
||||
then_branch: Box::new(ASTNode::Literal {
|
||||
then_body: vec![ASTNode::Literal {
|
||||
value: LiteralValue::Integer(1),
|
||||
span: Span::unknown(),
|
||||
}),
|
||||
else_branch: Some(Box::new(ASTNode::Literal {
|
||||
}],
|
||||
else_body: Some(vec![ASTNode::Literal {
|
||||
value: LiteralValue::Integer(2),
|
||||
span: Span::unknown(),
|
||||
})),
|
||||
}]),
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
@ -498,4 +499,4 @@ mod tests {
|
||||
let stats = function.stats();
|
||||
assert!(stats.phi_count >= 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//! Tests for NyashBox trait implementations
|
||||
use crate::box_trait::{NyashBox, StringBox, IntegerBox};
|
||||
use crate::box_trait::{NyashBox, StringBox, IntegerBox, BoxCore};
|
||||
use crate::boxes::{ArrayBox, BufferBox, JSONBox, NyashFutureBox, NyashStreamBox, NyashResultBox};
|
||||
|
||||
#[cfg(test)]
|
||||
@ -111,7 +111,7 @@ mod tests {
|
||||
let success_result = NyashResultBox::new_ok(Box::new(StringBox::new("success")));
|
||||
|
||||
assert_eq!(success_result.type_name(), "NyashResultBox");
|
||||
assert!(success_result.is_ok());
|
||||
assert!(success_result.is_ok_bool());
|
||||
assert!(!success_result.is_err());
|
||||
|
||||
let string_repr = success_result.to_string_box();
|
||||
@ -119,7 +119,7 @@ mod tests {
|
||||
|
||||
// Test error case
|
||||
let error_result = NyashResultBox::new_err(Box::new(StringBox::new("error")));
|
||||
assert!(!error_result.is_ok());
|
||||
assert!(!error_result.is_ok_bool());
|
||||
assert!(error_result.is_err());
|
||||
|
||||
let error_string = error_result.to_string_box();
|
||||
@ -140,4 +140,4 @@ mod tests {
|
||||
// but that's fine for our use case
|
||||
assert_eq!(cloned.type_name(), box1.type_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user