From 6143a9424568db964a571df708298579f70aa1f0 Mon Sep 17 00:00:00 2001 From: croraf Date: Wed, 10 Jun 2020 13:08:18 +0200 Subject: [PATCH 1/4] Fix and one test --- boa/src/exec/declaration/mod.rs | 2 +- boa/src/exec/tests.rs | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/boa/src/exec/declaration/mod.rs b/boa/src/exec/declaration/mod.rs index 192a8a168fa..9a49e3b8fd1 100644 --- a/boa/src/exec/declaration/mod.rs +++ b/boa/src/exec/declaration/mod.rs @@ -37,7 +37,7 @@ impl Executable for FunctionDecl { .environment .initialize_binding(self.name(), val.clone()); - Ok(val) + Ok(Value::undefined()) } } diff --git a/boa/src/exec/tests.rs b/boa/src/exec/tests.rs index 64ee6e4d5fc..eabb5c279d6 100644 --- a/boa/src/exec/tests.rs +++ b/boa/src/exec/tests.rs @@ -1,5 +1,24 @@ use crate::{builtins::Value, exec, exec::Interpreter, forward, realm::Realm}; +#[test] +fn function_declaration_returns_undefined() { + let scenario = r#" + function abc() {} + "#; + + assert_eq!(&exec(scenario), "undefined"); +} + +#[test] +fn empty_var_decl_undefined() { + let scenario = r#" + let b; + b == undefined; + "#; + + assert_eq!(&exec(scenario), "true"); +} + #[test] fn empty_let_decl_undefined() { let scenario = r#" @@ -21,16 +40,6 @@ fn semicolon_expression_stop() { assert_eq!(&exec(scenario), "1"); } -#[test] -fn empty_var_decl_undefined() { - let scenario = r#" - let b; - b == undefined; - "#; - - assert_eq!(&exec(scenario), "true"); -} - #[test] fn object_field_set() { let scenario = r#" From 4ee5aaac3870a030e9ceaeab2a25444eaa9624c2 Mon Sep 17 00:00:00 2001 From: croraf Date: Wed, 10 Jun 2020 13:15:09 +0200 Subject: [PATCH 2/4] Merge mess fix --- boa/src/exec/tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boa/src/exec/tests.rs b/boa/src/exec/tests.rs index b4648d5d5f5..f7fa0543156 100644 --- a/boa/src/exec/tests.rs +++ b/boa/src/exec/tests.rs @@ -17,6 +17,8 @@ fn empty_var_decl_undefined() { "#; assert_eq!(&exec(scenario), "true"); +} + fn property_accessor_member_expression_dot_notation_on_string_literal() { let scenario = r#" typeof 'asd'.matchAll; From 3a7f3a4b987fd87f2a16503dbd2872fcb1f779d2 Mon Sep 17 00:00:00 2001 From: croraf Date: Wed, 10 Jun 2020 13:25:15 +0200 Subject: [PATCH 3/4] More fixes --- boa/src/builtins/value/tests.rs | 2 +- boa/src/exec/tests.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/boa/src/builtins/value/tests.rs b/boa/src/builtins/value/tests.rs index a13883f19de..03975069c03 100644 --- a/boa/src/builtins/value/tests.rs +++ b/boa/src/builtins/value/tests.rs @@ -128,7 +128,7 @@ fn get_types() { forward_val(&mut engine, "function foo() {console.log(\"foo\");}") .unwrap() .get_type(), - Type::Function + Type::Undefined ); assert_eq!( forward_val(&mut engine, "null").unwrap().get_type(), diff --git a/boa/src/exec/tests.rs b/boa/src/exec/tests.rs index f7fa0543156..b094add7ba3 100644 --- a/boa/src/exec/tests.rs +++ b/boa/src/exec/tests.rs @@ -13,12 +13,13 @@ fn function_declaration_returns_undefined() { fn empty_var_decl_undefined() { let scenario = r#" let b; - b == undefined; + b === undefined; "#; assert_eq!(&exec(scenario), "true"); } +#[test] fn property_accessor_member_expression_dot_notation_on_string_literal() { let scenario = r#" typeof 'asd'.matchAll; From e4c7c5fbe753cacc687ebbad7a162eb42f91a19c Mon Sep 17 00:00:00 2001 From: croraf Date: Wed, 10 Jun 2020 14:03:43 +0200 Subject: [PATCH 4/4] Remove unnecessary clone as suggested by Clippy --- boa/src/exec/declaration/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boa/src/exec/declaration/mod.rs b/boa/src/exec/declaration/mod.rs index 9a49e3b8fd1..37f199003a4 100644 --- a/boa/src/exec/declaration/mod.rs +++ b/boa/src/exec/declaration/mod.rs @@ -35,7 +35,7 @@ impl Executable for FunctionDecl { interpreter .realm_mut() .environment - .initialize_binding(self.name(), val.clone()); + .initialize_binding(self.name(), val); Ok(Value::undefined()) }