MCPcopy Create free account
hub / github.com/d0iasm/saba / test_define_function_with_args

Function test_define_function_with_args

core/src/renderer/js/runtime.rs:640–655  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

638
639 #[test]
640 fn test_define_function_with_args() {
641 let dom = Rc::new(RefCell::new(DomNode::new(DomNodeKind::Document)));
642 let input = "function foo(a, b) { return a + b; } foo(1, 2) + 3;".to_string();
643 let lexer = JsLexer::new(input);
644 let mut parser = JsParser::new(lexer);
645 let ast = parser.parse_ast();
646 let mut runtime = JsRuntime::new(dom);
647 let expected = [None, Some(RuntimeValue::Number(6))];
648 let mut i = 0;
649
650 for node in ast.body() {
651 let result = runtime.eval(&Some(node.clone()), runtime.env.clone());
652 assert_eq!(expected[i], result);
653 i += 1;
654 }
655 }
656
657 #[test]
658 fn test_local_variable() {

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
parse_astMethod · 0.80
evalMethod · 0.80
bodyMethod · 0.45

Tested by

no test coverage detected