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

Function test_local_variable

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

Source from the content-addressed store, hash-verified

656
657 #[test]
658 fn test_local_variable() {
659 let dom = Rc::new(RefCell::new(DomNode::new(DomNodeKind::Document)));
660 let input = "var a=42; function foo() { var a=1; return a; } foo()+a".to_string();
661 let lexer = JsLexer::new(input);
662 let mut parser = JsParser::new(lexer);
663 let ast = parser.parse_ast();
664 let mut runtime = JsRuntime::new(dom);
665 let expected = [None, None, Some(RuntimeValue::Number(43))];
666 let mut i = 0;
667
668 for node in ast.body() {
669 let result = runtime.eval(&Some(node.clone()), runtime.env.clone());
670 assert_eq!(expected[i], result);
671 i += 1;
672 }
673 }
674
675 #[test]
676 fn test_browser_api() {

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