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

Function test_define_function

core/src/renderer/js/ast.rs:705–723  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

703
704 #[test]
705 fn test_define_function() {
706 let input = "function foo() { return 42; }".to_string();
707 let lexer = JsLexer::new(input);
708 let mut parser = JsParser::new(lexer);
709 let mut expected = Program::new();
710 let mut body = Vec::new();
711 body.push(Rc::new(Node::FunctionDeclaration {
712 id: Some(Rc::new(Node::Identifier("foo".to_string()))),
713 params: [].to_vec(),
714 body: Some(Rc::new(Node::BlockStatement {
715 body: [Some(Rc::new(Node::ReturnStatement {
716 argument: Some(Rc::new(Node::NumericLiteral(42))),
717 }))]
718 .to_vec(),
719 })),
720 }));
721 expected.set_body(body);
722 assert_eq!(expected, parser.parse_ast());
723 }
724
725 #[test]
726 fn test_define_function_with_args() {

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.80
set_bodyMethod · 0.80

Tested by

no test coverage detected