diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/if | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/if')
71 files changed, 1928 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1.1_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A1.1_T1.js new file mode 100644 index 0000000000..11708598fe --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1.1_T1.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 0, null, undefined, false, empty string, NaN in expression is evaluated + to false +es5id: 12.5_A1.1_T1 +description: Using "if" without "else" construction +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 + +if(0) + throw new Test262Error('#1: 0 in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(false) + throw new Test262Error('#2: false in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(null) + throw new Test262Error('#3: null in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(undefined) + throw new Test262Error('#4: undefined in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if("") + throw new Test262Error('#5: empty string in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(NaN) + throw new Test262Error('#5: NaN in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1.1_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A1.1_T2.js new file mode 100644 index 0000000000..f1d01e944e --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1.1_T2.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 0, null, undefined, false, empty string, NaN in expression is evaluated + to false +es5id: 12.5_A1.1_T2 +description: Using "if/else" construction +---*/ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(0) + throw new Test262Error('#1.1: 0 in expression is evaluated to false '); +else + c++; +if (c!=1) throw new Test262Error('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(false) + throw new Test262Error('#2.1: false in expression is evaluated to false '); +else + c++; +if (c!=2) throw new Test262Error('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(null) + throw new Test262Error('#3.1: null in expression is evaluated to false '); +else + c++; +if (c!=3) throw new Test262Error('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(undefined) + throw new Test262Error('#4.1: undefined in expression is evaluated to false '); +else + c++; +if (c!=4) throw new Test262Error('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if("") + throw new Test262Error('#5.1: empty string in expression is evaluated to false '); +else + c++; +if (c!=5) throw new Test262Error('#5.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(NaN) + throw new Test262Error('#6.1: NaN in expression is evaluated to false '); +else + c++; +if (c!=6) throw new Test262Error('#6.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1.2_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A1.2_T1.js new file mode 100644 index 0000000000..9c89635145 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1.2_T1.js @@ -0,0 +1,75 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 1, true, non-empty string and others in expression is evaluated to true + when using operator "new" +es5id: 12.5_A1.2_T1 +description: Using "if" without "else" construction +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(new Number(1))) + throw new Test262Error('#1: new 1 in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(new Boolean(true))) + throw new Test262Error('#2: new true in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!(new String("1"))) + throw new Test262Error('#3: new "1" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!(new String("A"))) + throw new Test262Error('#4: new "A" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if(!(new Boolean(false))) + throw new Test262Error('#2: new false in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(!(new Number(NaN))) + throw new Test262Error('#6: new NaN in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if(!(new Number(null))) + throw new Test262Error('#7: new null in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if(!(new String(undefined))) + throw new Test262Error('#8: new undefined in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#9 +if(!(new String(""))) + throw new Test262Error('#9: new empty string in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1.2_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A1.2_T2.js new file mode 100644 index 0000000000..278f576964 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1.2_T2.js @@ -0,0 +1,103 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 1, true, non-empty string and others in expression is evaluated to true + when using operator "new" +es5id: 12.5_A1.2_T2 +description: Using "if/else" construction +---*/ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(new Number(1))) + throw new Test262Error('#1.1: new 1 in expression is evaluated to true'); +else + c++; +if (c!=1) throw new Test262Error('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(new Boolean(true))) + throw new Test262Error('#2.1: new true in expression is evaluated to true'); +else + c++; +if (c!=2) throw new Test262Error('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!(new String("1"))) + throw new Test262Error('#3.1: new "1" in expression is evaluated to true'); +else + c++; +if (c!=3) throw new Test262Error('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!(new String("A"))) + throw new Test262Error('#4.1: new "A" in expression is evaluated to true'); +else + c++; +if (c!=4) throw new Test262Error('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if(!(new Boolean(false))) + throw new Test262Error('#5.1: new false in expression is evaluated to true '); +else + c++; +if (c!=5) throw new Test262Error('#5.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(!(new Number(NaN))) + throw new Test262Error('#6.1: new NaN in expression is evaluated to true '); +else + c++; +if (c!=6) throw new Test262Error('#6.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if(!(new Number(null))) + throw new Test262Error('#7.1: new null in expression is evaluated to true '); +else + c++; +if (c!=7) throw new Test262Error('#7.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if(!(new String(undefined))) + throw new Test262Error('#8.1: new undefined in expression is evaluated to true '); +else + c++; +if (c!=8) throw new Test262Error('#8.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#9 +if(!(new String(""))) + throw new Test262Error('#9.1: new empty string in expression is evaluated to true '); +else + c++; +if (c!=9) throw new Test262Error('#9.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A10_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A10_T1.js new file mode 100644 index 0000000000..144ec51b96 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A10_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function expession inside the "if" expression is allowed +es5id: 12.5_A10_T1 +description: > + Using function expession(function __func(){return 0;}) inside the + "if" expression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if(function __func(){return 0;}){ + ; +}else { + throw new Test262Error('#1: Function expession inside the "if" expression is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A10_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A10_T2.js new file mode 100644 index 0000000000..b919216368 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A10_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function expession inside the "if" expression is allowed +es5id: 12.5_A10_T2 +description: > + Using function expession "function __func(){return 0;}()" within + "if" expression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if(function __func(){return 0;}()){ + throw new Test262Error('#1: Function expession inside the if expression is allowed'); +}else { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A11.js b/js/src/tests/test262/language/statements/if/S12.5_A11.js new file mode 100644 index 0000000000..8e7c8d4c62 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A11.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "{} within the \"if\" expression is not allowed" +es5id: 12.5_A11 +description: Checking if execution of "if({1})" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if({1}) + { + ; + }else + { + ; + } +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/if/S12.5_A12_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A12_T1.js new file mode 100644 index 0000000000..b8750c099f --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A12_T1.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Embedded "if/else" constructions are allowed +es5id: 12.5_A12_T1 +description: Using embedded "if/else" into "if/else" constructions +---*/ + +//CHECK# 1 +if(true) + if (false) + throw new Test262Error('#1.1: At embedded "if/else" constructions engine must select right branches'); + else + ; +else + if (true) + throw new Test262Error('#1.2: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#1.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 2 +if(true) + if (true) + ; + else + throw new Test262Error('#2.1: At embedded "if/else" constructions engine must select right branches'); +else + if (true) + throw new Test262Error('#2.2: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#2.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + throw new Test262Error('#3.1: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#3.2: At embedded "if/else" constructions engine must select right branches'); +else + if (true) + ; + else + throw new Test262Error('#3.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + throw new Test262Error('#4.1: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#4.2: At embedded "if/else" constructions engine must select right branches'); +else + if (false) + throw new Test262Error('#4.3: At embedded "if/else" constructions engine must select right branches'); + else + ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A12_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A12_T2.js new file mode 100644 index 0000000000..34ec99c3c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A12_T2.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Embedded "if/else" constructions are allowed +es5id: 12.5_A12_T2 +description: Using embedded "if" into "if/else" constructions +---*/ + +//CHECK# 1 +if(true){ + if (false) + throw new Test262Error('#1.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (true) + throw new Test262Error('#1.2: At embedded "if/else" constructions engine must select right branches'); +} + +//CHECK# 2 +if(true){ + if (true) + ; +} +else{ + if (true) + throw new Test262Error('#2.2: At embedded "if/else" constructions engine must select right branches'); +} + +//CHECK# 3 +if(false){ + if (true) + throw new Test262Error('#3.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (true) + ; +} + +//CHECK# 4 +if(false){ + if (true) + throw new Test262Error('#4.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (false) + throw new Test262Error('#4.3: At embedded "if/else" constructions engine must select right branches'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A12_T3.js b/js/src/tests/test262/language/statements/if/S12.5_A12_T3.js new file mode 100644 index 0000000000..f068501d2c --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A12_T3.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Embedded "if/else" constructions are allowed +es5id: 12.5_A12_T3 +description: Using embedded "if/else" into "if" without "else" constructions +---*/ + +//CHECK# 1 +if(true) + if (false) + throw new Test262Error('#1.1: At embedded "if/else" constructions engine must select right branches'); + else + ; + +//CHECK# 2 +if(true) + if (true) + ; + else + throw new Test262Error('#2.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + throw new Test262Error('#3.1: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#3.2: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + throw new Test262Error('#4.1: At embedded "if/else" constructions engine must select right branches'); + else + throw new Test262Error('#4.2: At embedded "if/else" constructions engine must select right branches'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A12_T4.js b/js/src/tests/test262/language/statements/if/S12.5_A12_T4.js new file mode 100644 index 0000000000..5933e1d092 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A12_T4.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Embedded "if/else" constructions are allowed +es5id: 12.5_A12_T4 +description: Using embedded "if" into "if" constructions +---*/ + +//CHECK# 1 +if(true) + if (false) + throw new Test262Error('#1.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 2 +var c=0; +if(true) + if (true) + c=2; +if (c!==2) + throw new Test262Error('#2: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + throw new Test262Error('#3.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + throw new Test262Error('#4.1: At embedded "if/else" constructions engine must select right branches'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A1_T1.js new file mode 100644 index 0000000000..45b7820749 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1_T1.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1, true, non-empty string in expression is evaluated to true +es5id: 12.5_A1_T1 +description: Using "if" without "else" construction +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(1)) + throw new Test262Error('#1: 1 in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(true)) + throw new Test262Error('#2: true in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!("1")) + throw new Test262Error('#3: "1" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!("A")) + throw new Test262Error('#4: "A" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A1_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A1_T2.js new file mode 100644 index 0000000000..fb80e18739 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A1_T2.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1, true, non-empty string in expression is evaluated to true +es5id: 12.5_A1_T2 +description: Using "if/else" construction +---*/ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(1)) + throw new Test262Error('#1.1: 1 in expression is evaluated to true'); +else + c++; +if (c!=1) throw new Test262Error('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(true)) + throw new Test262Error('#2.1: true in expression is evaluated to true'); +else + c++; +if (c!=2) throw new Test262Error('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!("1")) + throw new Test262Error('#3.1: "1" in expression is evaluated to true'); +else + c++; +if (c!=3) throw new Test262Error('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!("A")) + throw new Test262Error('#4.1: "A" in expression is evaluated to true'); +else + c++; +if (c!=4) throw new Test262Error('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A2.js b/js/src/tests/test262/language/statements/if/S12.5_A2.js new file mode 100644 index 0000000000..cdd6ee9cad --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A2.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: In the "if" Statement eval in Expression is admitted +es5id: 12.5_A2 +description: Checking by using eval "eval("true")" +---*/ + +if (eval("true")) { +} else { + throw new Test262Error('#1: In the "if" Statement eval as Expression is admitted'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A3.js b/js/src/tests/test262/language/statements/if/S12.5_A3.js new file mode 100644 index 0000000000..d453858fe1 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A3.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the production "IfStatement: if ( Expression ) Statement else + Statement" is evaluated, Expression is evaluated first +es5id: 12.5_A3 +description: The Expression is "(function(){throw 1})()" +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + if ((function(){throw 1})()) abracadabra +} catch (e) { + if (e !== 1) { + throw new Test262Error('#1: Exception === 1. Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if ((function(){throw 1})()) abracadabra; else blablachat; +} catch (e) { + if (e !== 1) { + throw new Test262Error('#2: Exception === 1. Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A4.js b/js/src/tests/test262/language/statements/if/S12.5_A4.js new file mode 100644 index 0000000000..a73ebdacbc --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the production "IfStatement: if ( Expression ) Statement else + Statement" is evaluated, Statement(s) is(are) evaluated second +es5id: 12.5_A4 +description: The first statement is "(function(){throw "instatement"})()" +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + if (true) (function(){throw "instatement"})(); + throw new Test262Error("#1 failed") +} catch (e) { + if (e !== "instatement") { + throw new Test262Error('#1: Exception === "instatement". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if (false) (function(){throw "truebranch"})(); (function(){throw "missbranch"})(); + throw new Test262Error("#2 failed") +} catch (e) { + if (e !== "missbranch") { + throw new Test262Error('#2: Exception === "missbranch". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A5.js b/js/src/tests/test262/language/statements/if/S12.5_A5.js new file mode 100644 index 0000000000..bbf738f127 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A5.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + FunctionDeclaration inside the "if" Expression is evaluated as true and + function will not be declarated +es5id: 12.5_A5 +description: > + The "if" Expression is "function __func(){throw + "FunctionExpression";}" +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + __func=__func; + throw new Test262Error('#1: "__func=__func" lead to throwing exception'); +} catch (e) { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if(function __func(){throw "FunctionExpression";}) (function(){throw "TrueBranch"})(); else (function(){"MissBranch"})(); +} catch (e) { + if (e !== "TrueBranch") { + throw new Test262Error('#2: Exception ==="TrueBranch". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + __func=__func; + throw new Test262Error('#3: "__func=__func" lead to throwing exception'); +} catch (e) { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/S12.5_A6_T1.js b/js/src/tests/test262/language/statements/if/S12.5_A6_T1.js new file mode 100644 index 0000000000..294413d053 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A6_T1.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: In the If statement expression must be enclosed in braces +es5id: 12.5_A6_T1 +description: Checking if execution of "if true" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if true; +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/if/S12.5_A6_T2.js b/js/src/tests/test262/language/statements/if/S12.5_A6_T2.js new file mode 100644 index 0000000000..210514dba8 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A6_T2.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: In the If statement expression must be enclosed in braces +es5id: 12.5_A6_T2 +description: Checking if execution of "if false" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if false; +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/if/S12.5_A8.js b/js/src/tests/test262/language/statements/if/S12.5_A8.js new file mode 100644 index 0000000000..248b166a41 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/S12.5_A8.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: In the "if" Statement empty expression is not allowed +es5id: 12.5_A8 +description: Checking if execution of "if()" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(); +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/if/browser.js b/js/src/tests/test262/language/statements/if/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/browser.js diff --git a/js/src/tests/test262/language/statements/if/cptn-else-false-abrupt-empty.js b/js/src/tests/test262/language/statements/if/cptn-else-false-abrupt-empty.js new file mode 100644 index 0000000000..be9317eff1 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-else-false-abrupt-empty.js @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-runtime-semantics-evaluation +description: > + Completion value when expression is false with an `else` clause and body + returns an empty abrupt completion +info: | + IfStatement : if ( Expression ) Statement else Statement + + 3. If exprValue is true, then + [...] + 4. Else, + a. Let stmtCompletion be the result of evaluating the second Statement. + 5. Return Completion(UpdateEmpty(stmtCompletion, undefined)). +---*/ + +assert.sameValue( + eval('1; do { if (false) { } else { break; } } while (false)'), undefined +); +assert.sameValue( + eval('2; do { 3; if (false) { } else { break; } } while (false)'), undefined +); +assert.sameValue( + eval('4; do { if (false) { 5; } else { break; } } while (false)'), undefined +); +assert.sameValue( + eval('6; do { 7; if (false) { 8; } else { break; } } while (false)'), + undefined +); + +assert.sameValue( + eval('9; do { if (false) { } else { continue; } } while (false)'), undefined +); +assert.sameValue( + eval('10; do { 11; if (false) { } else { continue; } } while (false)'), + undefined +); +assert.sameValue( + eval('12; do { if (false) { 13; } else { continue; } } while (false)'), + undefined +); +assert.sameValue( + eval('14; do { 15; if (false) { 16; } else { continue; } } while (false)'), + undefined +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-else-false-nrml.js b/js/src/tests/test262/language/statements/if/cptn-else-false-nrml.js new file mode 100644 index 0000000000..cb31580666 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-else-false-nrml.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.6.7 +description: > + Completion value when expression is false with an `else` clause and body + returns a normal completion +info: | + IfStatement : if ( Expression ) Statement else Statement + + 4. If exprValue is true, then + [...] + 5. Else, + a. Let stmtCompletion be the result of evaluating the second Statement. + 6. ReturnIfAbrupt(stmtCompletion). + 7. If stmtCompletion.[[value]] is not empty, return stmtCompletion. + 8. Return NormalCompletion(undefined). +---*/ + +assert.sameValue(eval('1; if (false) { } else { }'), undefined); +assert.sameValue(eval('2; if (false) { } else { 3; }'), 3); +assert.sameValue(eval('4; if (false) { 5; } else { }'), undefined); +assert.sameValue(eval('6; if (false) { 7; } else { 8; }'), 8); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-else-true-abrupt-empty.js b/js/src/tests/test262/language/statements/if/cptn-else-true-abrupt-empty.js new file mode 100644 index 0000000000..b0c1678425 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-else-true-abrupt-empty.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-runtime-semantics-evaluation +description: > + Completion value when expression is true with an `else` clause and body + returns an abrupt completion +info: | + IfStatement : if ( Expression ) Statement else Statement + + 3. If exprValue is true, then + a. Let stmtCompletion be the result of evaluating the first Statement. + 4. Else, + [...] + 5. Return Completion(UpdateEmpty(stmtCompletion, undefined)). +---*/ + +assert.sameValue( + eval('1; do { if (true) { break; } else { } } while (false)'), undefined +); +assert.sameValue( + eval('2; do { 3; if (true) { break; } else { } } while (false)'), undefined +); +assert.sameValue( + eval('4; do { if (true) { break; } else { 5; } } while (false)'), undefined +); +assert.sameValue( + eval('6; do { 7; if (true) { break; } else { 8; } } while (false)'), + undefined +); + +assert.sameValue( + eval('1; do { if (true) { continue; } else { } } while (false)'), undefined +); +assert.sameValue( + eval('2; do { 3; if (true) { continue; } else { } } while (false)'), undefined +); +assert.sameValue( + eval('4; do { if (true) { continue; } else { 5; } } while (false)'), undefined +); +assert.sameValue( + eval('6; do { 7; if (true) { continue; } else { 8; } } while (false)'), + undefined +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-else-true-nrml.js b/js/src/tests/test262/language/statements/if/cptn-else-true-nrml.js new file mode 100644 index 0000000000..cf262e6a5b --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-else-true-nrml.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.6.7 +description: > + Completion value when expression is true with an `else` clause and body + returns a normal completion +info: | + IfStatement : if ( Expression ) Statement else Statement + + 4. If exprValue is true, then + a. Let stmtCompletion be the result of evaluating the first Statement. + 5. Else, + [...] + 6. ReturnIfAbrupt(stmtCompletion). + 7. If stmtCompletion.[[value]] is not empty, return stmtCompletion. + 8. Return NormalCompletion(undefined). +---*/ + +assert.sameValue(eval('1; if (true) { } else { }'), undefined); +assert.sameValue(eval('2; if (true) { 3; } else { }'), 3); +assert.sameValue(eval('4; if (true) { } else { 5; }'), undefined); +assert.sameValue(eval('6; if (true) { 7; } else { 8; }'), 7); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-empty-statement.js b/js/src/tests/test262/language/statements/if/cptn-empty-statement.js new file mode 100644 index 0000000000..d8b2c5bcd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-empty-statement.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + In the "if" statement empty statement is allowed and is evaluated to + "undefined" +es5id: 12.5_A7 +description: Checking by using eval "eval("if(1);"))" +---*/ + +var __evaluated = eval("if(1);"); + +assert.sameValue(__evaluated, undefined, '#1: __evaluated === undefined. Actual: __evaluated ==='+ __evaluated); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-no-else-false.js b/js/src/tests/test262/language/statements/if/cptn-no-else-false.js new file mode 100644 index 0000000000..3eff2032f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-no-else-false.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.6.7 +description: Completion value when expression is false without an `else` clause +info: | + IfStatement : if ( Expression ) Statement + + [...] + 4. If exprValue is false, then + a. Return NormalCompletion(undefined). +---*/ + +assert.sameValue(eval('1; if (false) { }'), undefined); +assert.sameValue(eval('2; if (false) { 3; }'), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-no-else-true-abrupt-empty.js b/js/src/tests/test262/language/statements/if/cptn-no-else-true-abrupt-empty.js new file mode 100644 index 0000000000..819497a063 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-no-else-true-abrupt-empty.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-runtime-semantics-evaluation +description: > + Completion value when expression is true without an `else` clause and body + returns an empty abrupt completion +info: | + IfStatement : if ( Expression ) Statement + + 3. If exprValue is false, then + [...] + 4. Else, + a. Let stmtCompletion be the result of evaluating Statement. + b. Return Completion(UpdateEmpty(stmtCompletion, undefined)). +---*/ + +assert.sameValue( + eval('1; do { 2; if (true) { 3; break; } 4; } while (false)'), 3 +); +assert.sameValue( + eval('5; do { 6; if (true) { break; } 7; } while (false)'), undefined +); + +assert.sameValue( + eval('8; do { 9; if (true) { 10; continue; } 11; } while (false)'), 10 +); +assert.sameValue( + eval('12; do { 13; if (true) { continue; } 14; } while (false)'), undefined +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/cptn-no-else-true-nrml.js b/js/src/tests/test262/language/statements/if/cptn-no-else-true-nrml.js new file mode 100644 index 0000000000..6b5f2ad1ae --- /dev/null +++ b/js/src/tests/test262/language/statements/if/cptn-no-else-true-nrml.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.6.7 +description: > + Completion value when expression is true without an `else` clause and body + returns a normal completion. +info: | + IfStatement : if ( Expression ) Statement + + [...] + 4. If exprValue is false, then + [...] + 5. Else, + a. Let stmtCompletion be the result of evaluating Statement. + b. ReturnIfAbrupt(stmtCompletion). + c. If stmtCompletion.[[value]] is not empty, return stmtCompletion. + d. Return NormalCompletion(undefined). +---*/ + +assert.sameValue(eval('1; if (true) { }'), undefined); +assert.sameValue(eval('2; if (true) { 3; }'), 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/empty-statement.js b/js/src/tests/test262/language/statements/if/empty-statement.js new file mode 100644 index 0000000000..eb58e5ffe3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/empty-statement.js @@ -0,0 +1,11 @@ +// Copyright 2019 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: In the "if" statement empty statement is allowed. +es5id: 12.5_A7 +---*/ + +if(1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/if-async-fun-else-async-fun.js b/js/src/tests/test262/language/statements/if/if-async-fun-else-async-fun.js new file mode 100644 index 0000000000..ce2f37bf32 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-fun-else-async-fun.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +if (true) async function f() { } else async function _f() {} diff --git a/js/src/tests/test262/language/statements/if/if-async-fun-else-stmt.js b/js/src/tests/test262/language/statements/if/if-async-fun-else-stmt.js new file mode 100644 index 0000000000..93e9241d8b --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-fun-else-stmt.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +if (true) async function f() { } else ; diff --git a/js/src/tests/test262/language/statements/if/if-async-fun-no-else.js b/js/src/tests/test262/language/statements/if/if-async-fun-no-else.js new file mode 100644 index 0000000000..5fc1ef0dd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-fun-no-else.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +if (true) async function f() { } diff --git a/js/src/tests/test262/language/statements/if/if-async-gen-else-async-gen.js b/js/src/tests/test262/language/statements/if/if-async-gen-else-async-gen.js new file mode 100644 index 0000000000..fd44f72614 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-gen-else-async-gen.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +if (true) async function* f() { } else async function* _f() {} diff --git a/js/src/tests/test262/language/statements/if/if-async-gen-else-stmt.js b/js/src/tests/test262/language/statements/if/if-async-gen-else-stmt.js new file mode 100644 index 0000000000..83a01db591 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-gen-else-stmt.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +if (true) async function* f() { } else ; diff --git a/js/src/tests/test262/language/statements/if/if-async-gen-no-else.js b/js/src/tests/test262/language/statements/if/if-async-gen-no-else.js new file mode 100644 index 0000000000..057c79c607 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-async-gen-no-else.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +if (true) async function* f() { } diff --git a/js/src/tests/test262/language/statements/if/if-cls-else-cls.js b/js/src/tests/test262/language/statements/if/if-cls-else-cls.js new file mode 100644 index 0000000000..37724e0cb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-cls-else-cls.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) class C {} else class D {} diff --git a/js/src/tests/test262/language/statements/if/if-cls-else-stmt.js b/js/src/tests/test262/language/statements/if/if-cls-else-stmt.js new file mode 100644 index 0000000000..7a1cb274a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-cls-else-stmt.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) class C {} else ; diff --git a/js/src/tests/test262/language/statements/if/if-cls-no-else.js b/js/src/tests/test262/language/statements/if/if-cls-no-else.js new file mode 100644 index 0000000000..aae8ab2977 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-cls-no-else.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) class C {} diff --git a/js/src/tests/test262/language/statements/if/if-const-else-const.js b/js/src/tests/test262/language/statements/if/if-const-else-const.js new file mode 100644 index 0000000000..c72e7f59f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-const-else-const.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) const x = null; else const y = null; diff --git a/js/src/tests/test262/language/statements/if/if-const-else-stmt.js b/js/src/tests/test262/language/statements/if/if-const-else-stmt.js new file mode 100644 index 0000000000..45835be19f --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-const-else-stmt.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) const x = null; else ; diff --git a/js/src/tests/test262/language/statements/if/if-const-no-else.js b/js/src/tests/test262/language/statements/if/if-const-no-else.js new file mode 100644 index 0000000000..7cd91b667f --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-const-no-else.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) const x = null; diff --git a/js/src/tests/test262/language/statements/if/if-decl-else-decl-strict-strict.js b/js/src/tests/test262/language/statements/if/if-decl-else-decl-strict-strict.js new file mode 100644 index 0000000000..2a3b6ae4e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-decl-else-decl-strict-strict.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in both statement positions in the global scope) +es6id: B.3.4 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() { } else function _f() {} diff --git a/js/src/tests/test262/language/statements/if/if-decl-else-stmt-strict-strict.js b/js/src/tests/test262/language/statements/if/if-decl-else-stmt-strict-strict.js new file mode 100644 index 0000000000..a6b4d3aaa7 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-decl-else-stmt-strict-strict.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the first statement position in the global scope) +es6id: B.3.4 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() { } else ; diff --git a/js/src/tests/test262/language/statements/if/if-decl-no-else-strict-strict.js b/js/src/tests/test262/language/statements/if/if-decl-no-else-strict-strict.js new file mode 100644 index 0000000000..a3b0bc241f --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-decl-no-else-strict-strict.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement without an else clause in the global scope) +es6id: B.3.4 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() { } diff --git a/js/src/tests/test262/language/statements/if/if-fun-else-fun-strict-strict.js b/js/src/tests/test262/language/statements/if/if-fun-else-fun-strict-strict.js new file mode 100644 index 0000000000..3aff76f3b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-fun-else-fun-strict-strict.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() {} else function _f() {} diff --git a/js/src/tests/test262/language/statements/if/if-fun-else-stmt-strict-strict.js b/js/src/tests/test262/language/statements/if/if-fun-else-stmt-strict-strict.js new file mode 100644 index 0000000000..9d89018bbd --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-fun-else-stmt-strict-strict.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() {} else ; diff --git a/js/src/tests/test262/language/statements/if/if-fun-no-else-strict-strict.js b/js/src/tests/test262/language/statements/if/if-fun-no-else-strict-strict.js new file mode 100644 index 0000000000..c79beace1a --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-fun-no-else-strict-strict.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement without an else clause in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +$DONOTEVALUATE(); + +if (true) function f() {} diff --git a/js/src/tests/test262/language/statements/if/if-gen-else-gen.js b/js/src/tests/test262/language/statements/if/if-gen-else-gen.js new file mode 100644 index 0000000000..917044da15 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-gen-else-gen.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +if (true) function* g() { } else function* _g() {} diff --git a/js/src/tests/test262/language/statements/if/if-gen-else-stmt.js b/js/src/tests/test262/language/statements/if/if-gen-else-stmt.js new file mode 100644 index 0000000000..bd5bc3cc59 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-gen-else-stmt.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +if (true) function* g() { } else ; diff --git a/js/src/tests/test262/language/statements/if/if-gen-no-else.js b/js/src/tests/test262/language/statements/if/if-gen-no-else.js new file mode 100644 index 0000000000..b405120b9f --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-gen-no-else.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +if (true) function* g() { } diff --git a/js/src/tests/test262/language/statements/if/if-let-else-let.js b/js/src/tests/test262/language/statements/if/if-let-else-let.js new file mode 100644 index 0000000000..cc61674b89 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-let-else-let.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) let x; else let y; diff --git a/js/src/tests/test262/language/statements/if/if-let-else-stmt.js b/js/src/tests/test262/language/statements/if/if-let-else-stmt.js new file mode 100644 index 0000000000..019a1a6f03 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-let-else-stmt.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) let x; else ; diff --git a/js/src/tests/test262/language/statements/if/if-let-no-else.js b/js/src/tests/test262/language/statements/if/if-let-no-else.js new file mode 100644 index 0000000000..66b4bf9640 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-let-no-else.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) let x; diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-async-fun.js b/js/src/tests/test262/language/statements/if/if-stmt-else-async-fun.js new file mode 100644 index 0000000000..34d5a63bdf --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-async-fun.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +if (false) ; else async function f() { } diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-async-gen.js b/js/src/tests/test262/language/statements/if/if-stmt-else-async-gen.js new file mode 100644 index 0000000000..51feb3f68c --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-async-gen.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +if (false) ; else async function* f() { } diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-cls.js b/js/src/tests/test262/language/statements/if/if-stmt-else-cls.js new file mode 100644 index 0000000000..50cfe82301 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-cls.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (false) ; else class C {} diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-const.js b/js/src/tests/test262/language/statements/if/if-stmt-else-const.js new file mode 100644 index 0000000000..b9dfa2dd7e --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-const.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (false) ; else const x = null; diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-decl-strict-strict.js b/js/src/tests/test262/language/statements/if/if-stmt-else-decl-strict-strict.js new file mode 100644 index 0000000000..1cb37c2ac6 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-decl-strict-strict.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the second statement position in the global scope) +es6id: B.3.4 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + 1. 1. Let strict be IsStrict of script + 2. If strict is *false*, then + [...] +---*/ + +$DONOTEVALUATE(); + +if (false) ; else function f() { } diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-fun-strict-strict.js b/js/src/tests/test262/language/statements/if/if-stmt-else-fun-strict-strict.js new file mode 100644 index 0000000000..1116b762fd --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-fun-strict-strict.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + 1. 1. Let strict be IsStrict of script + 2. If strict is *false*, then + [...] +---*/ + +$DONOTEVALUATE(); + +if (false) ; else function f() {} diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-gen.js b/js/src/tests/test262/language/statements/if/if-stmt-else-gen.js new file mode 100644 index 0000000000..4fdb6faeb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-gen.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +if (false) ; else function* g() { } diff --git a/js/src/tests/test262/language/statements/if/if-stmt-else-let.js b/js/src/tests/test262/language/statements/if/if-stmt-else-let.js new file mode 100644 index 0000000000..1004cbcff4 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/if-stmt-else-let.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (false) ; else let x; diff --git a/js/src/tests/test262/language/statements/if/labelled-fn-stmt-first.js b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-first.js new file mode 100644 index 0000000000..5dc561e7d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-first.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-static-semantics-early-errors +es6id: 13.6.1 +description: > + A labelled function declaration is never permitted in the first of two + Statement positions +info: | + IfStatement : + + if ( Expression ) Statement else Statement + if ( Expression ) Statement + + - It is a Syntax Error if IsLabelledFunction(Statement) is true. + + NOTE It is only necessary to apply this rule if the extension specified in + B.3.2 is implemented. + + In the absence of Annex B.3.2, a SyntaxError should be produced due to the + labelled function declaration itself. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (false) label1: label2: function test262() {} else ; diff --git a/js/src/tests/test262/language/statements/if/labelled-fn-stmt-lone.js b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-lone.js new file mode 100644 index 0000000000..0a18cd7316 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-lone.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-static-semantics-early-errors +es6id: 13.6.1 +description: > + A labelled function declaration is never permitted in the sole Statement + position +info: | + IfStatement : + + if ( Expression ) Statement else Statement + if ( Expression ) Statement + + - It is a Syntax Error if IsLabelledFunction(Statement) is true. + + NOTE It is only necessary to apply this rule if the extension specified in + B.3.2 is implemented. + + In the absence of Annex B.3.2, a SyntaxError should be produced due to the + labelled function declaration itself. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (false) label1: label2: function test262() {} diff --git a/js/src/tests/test262/language/statements/if/labelled-fn-stmt-second.js b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-second.js new file mode 100644 index 0000000000..9acb6cbfd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/labelled-fn-stmt-second.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-static-semantics-early-errors +es6id: 13.6.1 +description: > + A labelled function declaration is never permitted in the second of two + Statement positions +info: | + IfStatement : + + if ( Expression ) Statement else Statement + if ( Expression ) Statement + + - It is a Syntax Error if IsLabelledFunction(Statement) is true. + + NOTE It is only necessary to apply this rule if the extension specified in + B.3.2 is implemented. + + In the absence of Annex B.3.2, a SyntaxError should be produced due to the + labelled function declaration itself. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if (true) ; else label1: label2: function test262() {} diff --git a/js/src/tests/test262/language/statements/if/let-array-with-newline.js b/js/src/tests/test262/language/statements/if/let-array-with-newline.js new file mode 100644 index 0000000000..e81973a5e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/let-array-with-newline.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + ExpressionStatement has a lookahead restriction for `let [`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +if (false) let +[a] = 0; diff --git a/js/src/tests/test262/language/statements/if/let-block-with-newline.js b/js/src/tests/test262/language/statements/if/let-block-with-newline.js new file mode 100644 index 0000000000..4c158434c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/let-block-with-newline.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + ExpressionStatement doesn't have a lookahead restriction for `let {`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +flags: [noStrict] +---*/ + +if (false) let // ASI +{} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/let-identifier-with-newline.js b/js/src/tests/test262/language/statements/if/let-identifier-with-newline.js new file mode 100644 index 0000000000..29629fa4c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/let-identifier-with-newline.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + ExpressionStatement doesn't have a lookahead restriction for `let <binding-identifier>`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +flags: [noStrict] +---*/ + +if (false) let // ASI +x = 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/shell.js b/js/src/tests/test262/language/statements/if/shell.js new file mode 100644 index 0000000000..43295587f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/shell.js @@ -0,0 +1,16 @@ +// GENERATED, DO NOT EDIT +// file: tcoHelper.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/js/src/tests/test262/language/statements/if/tco-else-body-strict.js b/js/src/tests/test262/language/statements/if/tco-else-body-strict.js new file mode 100644 index 0000000000..64883d7e39 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/tco-else-body-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Statement within statement is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + if (false) { } else { return f(n - 1); } +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/if/tco-if-body-strict.js b/js/src/tests/test262/language/statements/if/tco-if-body-strict.js new file mode 100644 index 0000000000..85188bdc36 --- /dev/null +++ b/js/src/tests/test262/language/statements/if/tco-if-body-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Statement within statement is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + if (true) { return f(n - 1); } +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); |