Browse Source

Moved function decl tests

pull/836/head
Paul Lancaster 4 years ago
parent
commit
2b286f9b46
  1. 4
      boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs
  2. 23
      boa/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs

4
boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs

@ -1,14 +1,12 @@
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use crate::{ use crate::syntax::{
syntax::{
ast::{node::FunctionDecl, Keyword, Punctuator}, ast::{node::FunctionDecl, Keyword, Punctuator},
parser::{ parser::{
function::FormalParameters, function::FunctionBody, statement::BindingIdentifier, function::FormalParameters, function::FunctionBody, statement::BindingIdentifier,
AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser,
}, },
},
}; };
use std::io::Read; use std::io::Read;

23
boa/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs

@ -1 +1,24 @@
use crate::syntax::{ast::node::FunctionDecl, parser::tests::check_parser};
/// Function declaration parsing.
#[test]
fn function_declaration() {
check_parser(
"function hello() {}",
vec![FunctionDecl::new(Box::from("hello"), vec![], vec![]).into()],
);
}
/// Function declaration parsing with keywords.
#[test]
fn function_declaration_keywords() {
check_parser(
"function yield() {}",
vec![FunctionDecl::new(Box::from("yield"), vec![], vec![]).into()],
);
check_parser(
"function await() {}",
vec![FunctionDecl::new(Box::from("await"), vec![], vec![]).into()],
);
}

Loading…
Cancel
Save