use oxide_compiler::compiler::Compiler; use oxide_parser::Allocator; use oxide_vm::vm::Vm; fn eval(source: &str) -> String { let allocator = Allocator::default(); let program = match oxide_parser::parse(&allocator, source) { Ok(p) => p, Err(e) => return format!("parse error: {}", e[0].message), }; let module = match Compiler::new().compile(&program) { Ok(m) => m, Err(e) => return format!("compile error: {e}"), }; let mut vm = Vm::new(); match vm.run(&module) { Ok(result) => format!("{result}"), Err(e) => format!("vm error: {e}"), } } #[test] fn eval_coercion_null_equals_null() { assert_eq!(eval("null == null"), "true"); } #[test] fn eval_coercion_bool_equals_int() { assert_eq!(eval("false == 0"), "true"); } #[test] fn eval_not_falsy() { assert_eq!(eval("!0"), "true"); }