Update benchmarks and adjust tests

This commit updates benchmark values in several example files to reflect
minor performance variations. It also includes adjustments to
integration
and unit tests to align with recent changes in the type checking and VM
logic, specifically concerning closures and TCO handling.
This commit is contained in:
Michael Schimmel
2026-02-19 23:54:53 +01:00
parent 3c0f2ec8ce
commit 1331aabbe1
13 changed files with 108 additions and 71 deletions
+4 -19
View File
@@ -1,10 +1,6 @@
#[cfg(test)]
mod tests {
use std::rc::Rc;
use std::cell::RefCell;
use crate::ast::parser::Parser;
use crate::ast::compiler::binder::Binder;
use crate::ast::vm::VM;
use crate::ast::types::Value;
use crate::ast::nodes::UntypedKind;
use crate::ast::environment::Environment;
@@ -73,21 +69,10 @@ mod tests {
)
"#;
let mut parser = Parser::new(source).expect("Failed to create parser");
let ast = parser.parse_expression().expect("Failed to parse");
let globals = Rc::new(RefCell::new(std::collections::HashMap::new()));
let mut binder = Binder::new(globals.clone());
let bound_ast = binder.bind(&ast).expect("Failed to bind");
// Use the real TypeChecker instead of the dummy placeholder
let global_types = Rc::new(RefCell::new(std::collections::HashMap::new()));
let checker = crate::ast::compiler::TypeChecker::new(global_types);
let typed_ast = checker.check(bound_ast).expect("Type check failed");
let vm_globals = Rc::new(RefCell::new(Vec::new()));
let mut vm = VM::new(vm_globals);
let result = vm.run(&typed_ast);
let env = Environment::new();
let compiled = env.compile(source).expect("Failed to compile");
let linked = env.link(compiled);
let result = env.run(&linked);
match result {
Ok(Value::Int(val)) => assert_eq!(val, 20, "Closure should modify outer variable"),