Browse Source

Moved function decl tests

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

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

@ -1,13 +1,11 @@
#[cfg(test)]
mod tests;
use crate::{
syntax::{
ast::{node::FunctionDecl, Keyword, Punctuator},
parser::{
function::FormalParameters, function::FunctionBody, statement::BindingIdentifier,
AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser,
},
use crate::syntax::{
ast::{node::FunctionDecl, Keyword, Punctuator},
parser::{
function::FormalParameters, function::FunctionBody, statement::BindingIdentifier,
AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser,
},
};
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