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

Function test_define_function

core/src/renderer/js/token.rs:319–340  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317
318 #[test]
319 fn test_define_function() {
320 let input = "function foo() { return 42; }".to_string();
321 let mut lexer = JsLexer::new(input).peekable();
322 let expected = [
323 Token::Keyword("function".to_string()),
324 Token::Identifier("foo".to_string()),
325 Token::Punctuator('('),
326 Token::Punctuator(')'),
327 Token::Punctuator('{'),
328 Token::Keyword("return".to_string()),
329 Token::Number(42),
330 Token::Punctuator(';'),
331 Token::Punctuator('}'),
332 ]
333 .to_vec();
334 let mut i = 0;
335 while lexer.peek().is_some() {
336 assert_eq!(Some(expected[i].clone()), lexer.next());
337 i += 1;
338 }
339 assert!(lexer.peek().is_none());
340 }
341
342 #[test]
343 fn test_define_function_with_args() {

Callers

nothing calls this directly

Calls 1

to_stringMethod · 0.80

Tested by

no test coverage detected