From 4e54ee4297e3babf023c526b0dc22c6a189bd603 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Mon, 1 May 2023 06:18:02 +0200 Subject: [PATCH] Fix hoisting tests --- boa_parser/src/parser/statement/block/tests.rs | 18 +++++++++--------- boa_parser/src/parser/tests/mod.rs | 18 ++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/boa_parser/src/parser/statement/block/tests.rs b/boa_parser/src/parser/statement/block/tests.rs index 743415dc80a..55eae0e2034 100644 --- a/boa_parser/src/parser/statement/block/tests.rs +++ b/boa_parser/src/parser/statement/block/tests.rs @@ -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(), @@ -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, ); diff --git a/boa_parser/src/parser/tests/mod.rs b/boa_parser/src/parser/tests/mod.rs index 183e07d03d5..28fda835bf8 100644 --- a/boa_parser/src/parser/tests/mod.rs +++ b/boa_parser/src/parser/tests/mod.rs @@ -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" @@ -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(), @@ -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, );