Skip to content

Commit

Permalink
Fix hoisting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed May 1, 2023
1 parent c166769 commit 4e54ee4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
18 changes: 9 additions & 9 deletions boa_parser/src/parser/statement/block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ fn hoisting() {
function hello() { return 10 }
}",
vec![
Declaration::Function(Function::new(
Some(hello.into()),
FormalParameterList::default(),
vec![StatementListItem::Statement(Statement::Return(
Return::new(Some(Literal::from(10).into())),
))]
.into(),
))
.into(),
Statement::Var(VarDeclaration(
vec![Variable::from_identifier(
a.into(),
Expand All @@ -142,6 +133,15 @@ fn hoisting() {
UpdateTarget::Identifier(Identifier::new(a)),
)))
.into(),
Declaration::Function(Function::new(
Some(hello.into()),
FormalParameterList::default(),
vec![StatementListItem::Statement(Statement::Return(
Return::new(Some(Literal::from(10).into())),
))]
.into(),
))
.into(),
],
interner,
);
Expand Down
18 changes: 8 additions & 10 deletions boa_parser/src/parser/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ fn assign_operator_precedence() {
#[test]
fn hoisting() {
let interner = &mut Interner::default();
let hello = interner
.get_or_intern_static("hello", utf16!("hello"))
.into();
let hello = interner.get_or_intern_static("hello", utf16!("hello"));
let a = interner.get_or_intern_static("a", utf16!("a"));
check_script_parser(
r"
Expand All @@ -111,16 +109,10 @@ fn hoisting() {
function hello() { return 10 }",
vec![
Declaration::Function(Function::new(
Some(hello),
FormalParameterList::default(),
vec![Statement::Return(Return::new(Some(Literal::from(10).into()))).into()].into(),
))
.into(),
Statement::Var(VarDeclaration(
vec![Variable::from_identifier(
a.into(),
Some(Call::new(hello.into(), Box::default()).into()),
Some(Call::new(Identifier::new(hello).into(), Box::default()).into()),
)]
.try_into()
.unwrap(),
Expand All @@ -131,6 +123,12 @@ fn hoisting() {
UpdateTarget::Identifier(Identifier::new(a)),
)))
.into(),
Declaration::Function(Function::new(
Some(hello.into()),
FormalParameterList::default(),
vec![Statement::Return(Return::new(Some(Literal::from(10).into()))).into()].into(),
))
.into(),
],
interner,
);
Expand Down

0 comments on commit 4e54ee4

Please sign in to comment.