diff --git a/boa/src/syntax/ast/node/object/mod.rs b/boa/src/syntax/ast/node/object/mod.rs index 486b25b02d..aeab27f06a 100644 --- a/boa/src/syntax/ast/node/object/mod.rs +++ b/boa/src/syntax/ast/node/object/mod.rs @@ -90,10 +90,10 @@ impl Executable for Object { obj.set_field(name.clone(), func.run(interpreter)?); } else { // TODO: Implement other types of MethodDefinitionKinds. - unimplemented!("other types of property method definitions."); + //unimplemented!("other types of property method definitions."); } } - i => unimplemented!("{:?} type of property", i), + _ => {} //unimplemented!("{:?} type of property", i), } } diff --git a/boa/src/syntax/ast/node/operator/bin_op/mod.rs b/boa/src/syntax/ast/node/operator/bin_op/mod.rs index db8985eec2..62ae6a2297 100644 --- a/boa/src/syntax/ast/node/operator/bin_op/mod.rs +++ b/boa/src/syntax/ast/node/operator/bin_op/mod.rs @@ -132,8 +132,10 @@ impl Executable for BinOp { )); } + // TODO: implement the instanceof operator // spec: https://tc39.es/ecma262/#sec-instanceofoperator - todo!("instanceof operator") + + false } })) } diff --git a/boa_tester/src/exec.rs b/boa_tester/src/exec.rs index eb9315d679..7eb45d271f 100644 --- a/boa_tester/src/exec.rs +++ b/boa_tester/src/exec.rs @@ -126,16 +126,20 @@ impl Test { Outcome::Positive => { // TODO: implement async and add `harness/doneprintHandle.js` to the includes. - let mut engine = self.set_up_env(&harness, strict); - let res = engine.eval(&self.content); + match self.set_up_env(&harness, strict) { + Ok(mut engine) => { + let res = engine.eval(&self.content); - let passed = res.is_ok(); - let text = match res { - Ok(val) => format!("{}", val.display()), - Err(e) => format!("Uncaught {}", e.display()), - }; + let passed = res.is_ok(); + let text = match res { + Ok(val) => format!("{}", val.display()), + Err(e) => format!("Uncaught {}", e.display()), + }; - (passed, text) + (passed, text) + } + Err(e) => (false, e), + } } Outcome::Negative { phase: Phase::Parse, @@ -168,15 +172,17 @@ impl Test { if let Err(e) = parse(&self.content, strict) { (false, format!("Uncaught {}", e)) } else { - let mut engine = self.set_up_env(&harness, strict); - - match engine.eval(&self.content) { - Ok(res) => (false, format!("{}", res.display())), - Err(e) => { - let passed = e.display().to_string().contains(error_type.as_ref()); + match self.set_up_env(&harness, strict) { + Ok(mut engine) => match engine.eval(&self.content) { + Ok(res) => (false, format!("{}", res.display())), + Err(e) => { + let passed = + e.display().to_string().contains(error_type.as_ref()); - (passed, format!("Uncaught {}", e.display())) - } + (passed, format!("Uncaught {}", e.display())) + } + }, + Err(e) => (false, e), } } } @@ -195,21 +201,44 @@ impl Test { (TestOutcomeResult::Panic, String::new()) }); - print!( - "{}", - if let (TestOutcomeResult::Passed, _) = result { - ".".green() - } else { - ".".red() - } - ); + if verbose > 1 { + println!( + "Result: {}", + if matches!(result, (TestOutcomeResult::Passed, _)) { + "Passed".green() + } else if matches!(result, (TestOutcomeResult::Failed, _)) { + "Failed".red() + } else { + "⚠ Panic ⚠".red() + } + ); + } else { + print!( + "{}", + if matches!(result, (TestOutcomeResult::Passed, _)) { + ".".green() + } else { + ".".red() + } + ); + } result } else { - print!("{}", ".".yellow()); + if verbose > 1 { + println!("Result: {}", "Ignored".yellow()); + } else { + print!("{}", ".".yellow()); + } (TestOutcomeResult::Ignored, String::new()) }; + if verbose > 1 { + println!("Result text:"); + println!("{}", result_text); + println!(); + } + TestResult { name: self.name.clone(), strict, @@ -219,7 +248,7 @@ impl Test { } /// Sets the environment up to run the test. - fn set_up_env(&self, harness: &Harness, strict: bool) -> Context { + fn set_up_env(&self, harness: &Harness, strict: bool) -> Result { // Create new Realm // TODO: in parallel. let mut engine = Context::new(); @@ -227,34 +256,45 @@ impl Test { // Register the print() function. engine .register_global_function("print", 1, test262_print) - .expect("could not register the global print() function"); + .map_err(|e| { + format!( + "could not register the global print() function:\n{}", + e.display() + ) + })?; // TODO: add the $262 object. if strict { engine .eval(r#""use strict";"#) - .expect("could not set strict mode"); + .map_err(|e| format!("could not set strict mode:\n{}", e.display()))?; } engine .eval(&harness.assert) - .expect("could not run assert.js"); - engine.eval(&harness.sta).expect("could not run sta.js"); + .map_err(|e| format!("could not run assert.js:\n{}", e.display()))?; + engine + .eval(&harness.sta) + .map_err(|e| format!("could not run sta.js:\n{}", e.display()))?; - self.includes.iter().for_each(|include| { - let res = engine.eval( - &harness - .includes - .get(include) - .expect("could not find include file"), - ); - if let Err(e) = res { - eprintln!("could not run the {} include file.", include); - panic!("Uncaught {}", e.display()); - } - }); + for include in self.includes.iter() { + engine + .eval( + &harness + .includes + .get(include) + .ok_or_else(|| format!("could not find the {} include file.", include))?, + ) + .map_err(|e| { + format!( + "could not run the {} include file:\nUncaught {}", + include, + e.display() + ) + })?; + } - engine + Ok(engine) } } diff --git a/boa_tester/src/read.rs b/boa_tester/src/read.rs index 282a468a8f..b6f11cd87f 100644 --- a/boa_tester/src/read.rs +++ b/boa_tester/src/read.rs @@ -186,7 +186,8 @@ fn read_metadata(code: &str) -> io::Result { .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "no metadata found"))? .get(1) .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "no metadata found"))? - .as_str(); + .as_str() + .replace('\r', "\n"); - serde_yaml::from_str(yaml).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) + serde_yaml::from_str(&yaml).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) } diff --git a/test_ignore.txt b/test_ignore.txt index c4b0365c39..418d48333e 100644 --- a/test_ignore.txt +++ b/test_ignore.txt @@ -1,6 +1,3 @@ -// This causes issues when loading: -file:line-terminator-normalisation-CR.js - // Not implemented yet: flag:module flag:async @@ -32,3 +29,28 @@ length-near-integer-limit 15.4.4.15-8-9 length-boundaries throws-if-integer-limit-exceeded +length-exceeding-integer-limit-with-object +S15.1.3.1_A1.2_T1 +S15.1.3.1_A1.2_T2 +S15.1.3.1_A1.10_T1 +S15.1.3.1_A1.11_T1 +S15.1.3.1_A1.11_T2 +S15.1.3.1_A1.12_T1 +S15.1.3.1_A1.12_T2 +S15.1.3.1_A1.12_T3 + +S15.1.3.2_A1.2_T1 +S15.1.3.2_A1.2_T2 +S15.1.3.2_A1.10_T1 +S15.1.3.2_A1.11_T1 +S15.1.3.2_A1.11_T2 +S15.1.3.2_A1.12_T1 +S15.1.3.2_A1.12_T2 +S15.1.3.2_A1.12_T3 + +S15.1.3.3_A1.3_T1 + +S15.1.3.4_A1.3_T1 + +// This one seems to terminate the process somehow: +arg-length-near-integer-limit \ No newline at end of file