feat: add Test effect and native testing framework
- Add Test effect with operations: assert, assertEqual, assertNotEqual, assertTrue, assertFalse, fail - Implement Test effect handlers in interpreter with TestResults tracking - Add values_equal method for comparing Value types in tests - Update lux test command to discover and run test_* functions - Create example test files: test_math.lux, test_lists.lux - Add TESTING_DESIGN.md documentation - Fix AST mismatches in C backend and compiler.rs for compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
50
src/types.rs
50
src/types.rs
@@ -1123,6 +1123,56 @@ impl TypeEnv {
|
||||
},
|
||||
);
|
||||
|
||||
// Add Test effect for test framework
|
||||
env.effects.insert(
|
||||
"Test".to_string(),
|
||||
EffectDef {
|
||||
name: "Test".to_string(),
|
||||
type_params: Vec::new(),
|
||||
operations: vec![
|
||||
EffectOpDef {
|
||||
name: "assert".to_string(),
|
||||
params: vec![
|
||||
("condition".to_string(), Type::Bool),
|
||||
("message".to_string(), Type::String),
|
||||
],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "assertEqual".to_string(),
|
||||
params: vec![
|
||||
("expected".to_string(), Type::Var(0)),
|
||||
("actual".to_string(), Type::Var(0)),
|
||||
],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "assertNotEqual".to_string(),
|
||||
params: vec![
|
||||
("a".to_string(), Type::Var(0)),
|
||||
("b".to_string(), Type::Var(0)),
|
||||
],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "assertTrue".to_string(),
|
||||
params: vec![("condition".to_string(), Type::Bool)],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "assertFalse".to_string(),
|
||||
params: vec![("condition".to_string(), Type::Bool)],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "fail".to_string(),
|
||||
params: vec![("message".to_string(), Type::String)],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
// Add Some and Ok, Err constructors
|
||||
// Some : fn(a) -> Option<a>
|
||||
let a = Type::var();
|
||||
|
||||
Reference in New Issue
Block a user