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

Function test_browser_api

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

Source from the content-addressed store, hash-verified

674
675 #[test]
676 fn test_browser_api() {
677 let dom = Rc::new(RefCell::new(DomNode::new(DomNodeKind::Document)));
678 let input = "document.getElementById(\"target\")".to_string();
679 let lexer = JsLexer::new(input);
680 let mut parser = JsParser::new(lexer);
681 let ast = parser.parse_ast();
682 let mut runtime = JsRuntime::new(dom);
683 let expected = [None, None, Some(RuntimeValue::Number(43))];
684 let mut i = 0;
685
686 for node in ast.body() {
687 let result = runtime.eval(&Some(node.clone()), runtime.env.clone());
688 assert_eq!(expected[i], result);
689 i += 1;
690 }
691 }
692}

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