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

Function test_add_variable_and_num

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

Source from the content-addressed store, hash-verified

563
564 #[test]
565 fn test_add_variable_and_num() {
566 let dom = Rc::new(RefCell::new(DomNode::new(DomNodeKind::Document)));
567 let input = "var foo=42; foo+1".to_string();
568 let lexer = JsLexer::new(input);
569 let mut parser = JsParser::new(lexer);
570 let ast = parser.parse_ast();
571 let mut runtime = JsRuntime::new(dom);
572 let expected = [None, Some(RuntimeValue::Number(43))];
573 let mut i = 0;
574
575 for node in ast.body() {
576 let result = runtime.eval(&Some(node.clone()), runtime.env.clone());
577 assert_eq!(expected[i], result);
578 i += 1;
579 }
580 }
581
582 #[test]
583 fn test_reassign_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