diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/conditional')
24 files changed, 606 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A1.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A1.js new file mode 100644 index 0000000000..f16b32fb76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A1.js @@ -0,0 +1,63 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + White Space and Line Terminator between LogicalORExpression and "?" or + between "?" and AssignmentExpression or between AssignmentExpression and + ":" or between ":" and AssignmentExpression are allowed +es5id: 11.12_A1 +description: Checking by using eval +---*/ + +//CHECK#1 +if ((eval("false\u0009?\u0009true\u0009:\u0009true")) !== true) { + throw new Test262Error('#1: (false\\u0009?\\u0009true\\u0009:\\u0009true) === true'); +} + +//CHECK#2 +if ((eval("false\u000B?\u000Btrue\u000B:\u000Btrue")) !== true) { + throw new Test262Error('#2: (false\\u000B?\\u000Btrue\\u000B:\\u000Btrue) === true'); +} + +//CHECK#3 +if ((eval("false\u000C?\u000Ctrue\u000C:\u000Ctrue")) !== true) { + throw new Test262Error('#3: (false\\u000C?\\u000Ctrue\\u000C:\\u000Ctrue) === true'); +} + +//CHECK#4 +if ((eval("false\u0020?\u0020true\u0020:\u0020true")) !== true) { + throw new Test262Error('#4: (false\\u0020?\\u0020true\\u0020:\\u0020true) === true'); +} + +//CHECK#5 +if ((eval("false\u00A0?\u00A0true\u00A0:\u00A0true")) !== true) { + throw new Test262Error('#5: (false\\u00A0?\\u00A0true\\u00A0:\\u00A0true) === true'); +} + +//CHECK#6 +if ((eval("false\u000A?\u000Atrue\u000A:\u000Atrue")) !== true) { + throw new Test262Error('#6: (false\\u000A?\\u000Atrue\\u000A:\\u000Atrue) === true'); +} + +//CHECK#7 +if ((eval("false\u000D?\u000Dtrue\u000D:\u000Dtrue")) !== true) { + throw new Test262Error('#7: (false\\u000D?\\u000Dtrue\\u000D:\\u000Dtrue) === true'); +} + +//CHECK#8 +if ((eval("false\u2028?\u2028true\u2028:\u2028true")) !== true) { + throw new Test262Error('#8: (false\\u2028?\\u2028true\\u2028:\\u2028true) === true'); +} + +//CHECK#9 +if ((eval("false\u2029?\u2029true\u2029:\u2029true")) !== true) { + throw new Test262Error('#9: (false\\u2029?\\u2029true\\u2029:\\u2029true) === true'); +} + +//CHECK#10 +if ((eval("false\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029?\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029true\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029:\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029true")) !== true) { + throw new Test262Error('#10: (false\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029?\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029true\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029:\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029true) === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T1.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T1.js new file mode 100644 index 0000000000..4859764b0d --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T1.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: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T1 +description: Either Type is not Reference or GetBase is not null +---*/ + +//CHECK#1 +if ((true ? false : true) !== false) { + throw new Test262Error('#1: (true ? false : true) === false'); +} + +//CHECK#2 +if ((false ? false : true) !== true) { + throw new Test262Error('#2: (false ? false : true) === true'); +} + +//CHECK#3 +var x = new Boolean(true); +var y = new Boolean(false); +if ((x ? y : true) !== y) { + throw new Test262Error('#3: var x = new Boolean(true); var y = new Boolean(false); (x ? y : true) === y'); +} + +//CHECK#4 +var z = new Boolean(true); +if ((false ? false : z) !== z) { + throw new Test262Error('#4: var z = new Boolean(true); (false ? false : z) === z'); +} + +//CHECK#5 +var x = new Boolean(true); +var y = new Boolean(false); +var z = new Boolean(true); +if ((x ? y : z) !== y) { + throw new Test262Error('#5: var x = new Boolean(true); var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === y'); +} + +//CHECK#6 +var x = false; +var y = new Boolean(false); +var z = new Boolean(true); +if ((x ? y : z) !== z) { + throw new Test262Error('#6: var x = false; var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === z'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T2.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T2.js new file mode 100644 index 0000000000..af5a146748 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T2 +description: If GetBase(x) is null, throw ReferenceError +---*/ + +//CHECK#1 +try { + x ? true : false; + throw new Test262Error('#1.1: x ? true : false throw ReferenceError. Actual: ' + (x ? true : false)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: x ? true : false throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T3.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T3.js new file mode 100644 index 0000000000..7153bf8896 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T3 +description: > + If ToBoolean(x) is true and GetBase(y) is null, throw + ReferenceError +---*/ + +//CHECK#1 +try { + true ? y : false; + throw new Test262Error('#1.1: true ? y : false throw ReferenceError. Actual: ' + (true ? y : false)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: true ? y : false throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T4.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T4.js new file mode 100644 index 0000000000..8eb9fe4fa9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T4.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T4 +description: > + If ToBoolean(x) is false and GetBase(z) is null, throw + ReferenceError +---*/ + +//CHECK#1 +try { + false ? true : z; + throw new Test262Error('#1.1: false ? true : z throw ReferenceError. Actual: ' + (false ? true : z)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: false ? true : z throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T5.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T5.js new file mode 100644 index 0000000000..202243cf02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T5.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: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T5 +description: If ToBoolean(x) is true and GetBase(z) is null, return y +---*/ + +//CHECK#1 +var y = new Object(); +if ((true ? y : z) !== y) { + throw new Test262Error('#1: var y = new Object(); (true ? y : z) === y'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T6.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T6.js new file mode 100644 index 0000000000..543da3822b --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A2.1_T6.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: "Operator x ? y : z uses GetValue" +es5id: 11.12_A2.1_T6 +description: If ToBoolean(x) is false and GetBase(y) is null, return z +---*/ + +//CHECK#1 +var z = new Object(); +if ((false ? y : z) !== z) { + throw new Test262Error('#1: var z = new Object(); (false ? y : z) === z'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T1.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T1.js new file mode 100644 index 0000000000..ac41442d8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is false, return z +es5id: 11.12_A3_T1 +description: Type(y) and Type(z) are boolean primitives +---*/ + +//CHECK#1 +if ((false ? false : true) !== true) { + throw new Test262Error('#1: (false ? false : true) === true'); +} + +//CHECK#2 +var z = new Boolean(true); +if ((false ? true : z) !== z) { + throw new Test262Error('#2: (var y = new Boolean(true); (false ? true : z) === z'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T2.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T2.js new file mode 100644 index 0000000000..567736d830 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is false, return z +es5id: 11.12_A3_T2 +description: Type(y) and Type(z) are number primitives +---*/ + +//CHECK#1 +if ((0 ? 0 : 1) !== 1) { + throw new Test262Error('#1: (0 ? 0 : 1) === 1'); +} + +//CHECK#2 +var z = new Number(1); +if ((0 ? 1 : z) !== z) { + throw new Test262Error('#2: (var y = new Number(1); (0 ? 1 : z) === z'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T3.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T3.js new file mode 100644 index 0000000000..6b705fc0b2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is false, return z +es5id: 11.12_A3_T3 +description: Type(y) and Type(z) are string primitives +---*/ + +//CHECK#1 +if (("" ? "" : "1") !== "1") { + throw new Test262Error('#1: ("" ? "" : "1") === "1"'); +} + +//CHECK#2 +var z = new String("1"); +if (("" ? "1" : z) !== z) { + throw new Test262Error('#2: (var y = new String("1"); ("" ? "1" : z) === z'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T4.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T4.js new file mode 100644 index 0000000000..05812b3093 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A3_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is false, return z +es5id: 11.12_A3_T4 +description: Type(x) or Type(y) is changed between null and undefined +---*/ + +//CHECK#1 +if ((false ? true : undefined) !== undefined) { + throw new Test262Error('#1: (false ? true : undefined) === undefined'); +} + +//CHECK#2 +if ((false ? true : null) !== null) { + throw new Test262Error('#2: (false ? true : null) === null'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T1.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T1.js new file mode 100644 index 0000000000..6ff8031efa --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is true, return y +es5id: 11.12_A4_T1 +description: Type(y) and Type(z) are boolean primitives +---*/ + +//CHECK#1 +if ((true ? false : true) !== false) { + throw new Test262Error('#1: (true ? false : true) === false'); +} + +//CHECK#2 +var y = new Boolean(true); +if ((true ? y : false) !== y) { + throw new Test262Error('#2: (var y = new Boolean(true); (true ? y : false) === y'); +} + +//CHECK#3 +var y = new Boolean(false); +if ((y ? y : true) !== y) { + throw new Test262Error('#3: (var y = new Boolean(false); (y ? y : true) === y'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T2.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T2.js new file mode 100644 index 0000000000..997de777f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T2.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is true, return y +es5id: 11.12_A4_T2 +description: Type(y) and Type(z) are number primitives +---*/ + +//CHECK#1 +if ((1 ? 0 : 1) !== 0) { + throw new Test262Error('#1: (1 ? 0 : 1) === 0'); +} + +//CHECK#2 +var y = new Number(1); +if ((1 ? y : 0) !== y) { + throw new Test262Error('#2: (var y = new Number(1); (1 ? y : 0) === y'); +} + +//CHECK#3 +var y = new Number(NaN); +if ((y ? y : 1) !== y) { + throw new Test262Error('#3: (var y = new Number(NaN); (y ? y : 1) === y'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T3.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T3.js new file mode 100644 index 0000000000..7d5b4b9643 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T3.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is true, return y +es5id: 11.12_A4_T3 +description: Type(y) and Type(z) are string primitives +---*/ + +//CHECK#1 +if (("1" ? "" : "1") !== "") { + throw new Test262Error('#1: ("1" ? "" : "1") === ""'); +} + +//CHECK#2 +var y = new String("1"); +if (("1" ? y : "") !== y) { + throw new Test262Error('#2: (var y = new String("1"); ("1" ? y : "") === y'); +} + +//CHECK#3 +var y = new String("y"); +if ((y ? y : "1") !== y) { + throw new Test262Error('#3: (var y = new String("y"); (y ? y : "1") === y'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T4.js b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T4.js new file mode 100644 index 0000000000..1ec3450deb --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/S11.12_A4_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToBoolean(x) is true, return y +es5id: 11.12_A4_T4 +description: Type(x) or Type(y) is changed between null and undefined +---*/ + +//CHECK#1 +if ((true ? undefined : true) !== undefined) { + throw new Test262Error('#1: (true ? undefined : true) === undefined'); +} + +//CHECK#2 +if ((true ? null : true) !== null) { + throw new Test262Error('#2: (true ? null : true) === null'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/browser.js b/js/src/tests/test262/language/expressions/conditional/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/browser.js diff --git a/js/src/tests/test262/language/expressions/conditional/coalesce-expr-ternary.js b/js/src/tests/test262/language/expressions/conditional/coalesce-expr-ternary.js new file mode 100644 index 0000000000..543f22127a --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/coalesce-expr-ternary.js @@ -0,0 +1,75 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + ShortCircuitExpression in the Conditional Expression (? :) +esid: sec-conditional-operator +info: | + ShortCircuitExpression : + LogicalORExpression + CoalesceExpression + + CoalesceExpression : + CoalesceExpressionHead ?? BitwiseORExpression + + CoalesceExpressionHead : + CoalesceExpression + BitwiseORExpression + + ConditionalExpression : + ShortCircuitExpression + ShortCircuitExpression ? AssignmentExpression : AssignmentExpression +features: [coalesce-expression] +---*/ + +var x; + +x = undefined ?? true ? 0 : 42; +assert.sameValue(x, 0, 'undefined ?? true ? 0 : 42'); + +x = undefined; +x = null ?? true ? 0 : 42; +assert.sameValue(x, 0, 'null ?? true ? 0 : 42'); + +x = undefined; +x = undefined ?? false ? 0 : 42; +assert.sameValue(x, 42, 'undefined ?? false ? 0 : 42'); + +x = undefined; +x = null ?? false ? 0 : 42; +assert.sameValue(x, 42, 'null ?? false ? 0 : 42'); + +x = undefined; +x = false ?? true ? 0 : 42; +assert.sameValue(x, 42, 'false ?? true ? 0 : 42'); + +x = undefined; +x = 0 ?? true ? 0 : 42; +assert.sameValue(x, 42, '0 ?? true ? 0 : 42'); + +x = undefined; +x = 1 ?? false ? 0 : 42; +assert.sameValue(x, 0, '1 ?? false ? 0 : 42'); + +x = undefined; +x = true ?? false ? 0 : 42; +assert.sameValue(x, 0, 'true ?? false ? 0 : 42'); + +x = undefined; +x = true ?? true ? 0 : 42; +assert.sameValue(x, 0, 'true ?? true ? 0 : 42'); + +x = undefined; +x = '' ?? true ? 0 : 42; +assert.sameValue(x, 42, '"" ?? true ? 0 : 42'); + +x = undefined; +x = Symbol() ?? false ? 0 : 42; +assert.sameValue(x, 0, 'Symbol() ?? false ? 0 : 42'); + +x = undefined; +x = {} ?? false ? 0 : 42; +assert.sameValue(x, 0, 'object ?? false ? 0 : 42'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/in-branch-1.js b/js/src/tests/test262/language/expressions/conditional/in-branch-1.js new file mode 100644 index 0000000000..7ae7ef62b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/in-branch-1.js @@ -0,0 +1,30 @@ +// 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-conditional-operator +es6id: 12.13 +description: > + The first AssignmentExpression may include the `in` keyword in any context +info: | + Syntax + + ConditionalExpression[In, Yield] : + LogicalORExpression[?In, ?Yield] + LogicalORExpression[?In, ?Yield] ? AssignmentExpression[+In, ?Yield] : AssignmentExpression[?In, ?Yield] +---*/ + +var cond1Count = 0; +var cond2Count = 0; +var cond1 = function() { + cond1Count += 1; + return {}; +}; +var cond2 = function() { + cond2Count += 1; +}; +for (true ? '' in cond1() : cond2(); false; ) ; + +assert.sameValue(cond1Count, 1); +assert.sameValue(cond2Count, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/in-branch-2.js b/js/src/tests/test262/language/expressions/conditional/in-branch-2.js new file mode 100644 index 0000000000..ce37772cd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/in-branch-2.js @@ -0,0 +1,23 @@ +// |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-conditional-operator +es6id: 12.13 +description: > + The second AssignmentExpression cannot include the `in` keyword in contexts + where it is disallowed. +info: | + Syntax + + ConditionalExpression[In, Yield] : + LogicalORExpression[?In, ?Yield] + LogicalORExpression[?In, ?Yield] ? AssignmentExpression[+In, ?Yield] : AssignmentExpression[?In, ?Yield] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for (true ? 0 : 0 in {}; false; ) ; diff --git a/js/src/tests/test262/language/expressions/conditional/in-condition.js b/js/src/tests/test262/language/expressions/conditional/in-condition.js new file mode 100644 index 0000000000..5cbb70c50d --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/in-condition.js @@ -0,0 +1,23 @@ +// |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-conditional-operator +es6id: 12.13 +description: > + The expression's LogicalORExpression sub-expression cannot include the `in` + keyword in contexts where it is disallowed. +info: | + Syntax + + ConditionalExpression[In, Yield] : + LogicalORExpression[?In, ?Yield] + LogicalORExpression[?In, ?Yield] ? AssignmentExpression[+In, ?Yield] : AssignmentExpression[?In, ?Yield] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for ('' in {} ? 0 : 0; false; ) ; diff --git a/js/src/tests/test262/language/expressions/conditional/shell.js b/js/src/tests/test262/language/expressions/conditional/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/shell.js diff --git a/js/src/tests/test262/language/expressions/conditional/symbol-conditional-evaluation.js b/js/src/tests/test262/language/expressions/conditional/symbol-conditional-evaluation.js new file mode 100644 index 0000000000..35c95a12aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/symbol-conditional-evaluation.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.12.3 +description: > + Conditional Symbol evaluation +features: [Symbol] +---*/ +var sym = Symbol(); + +assert.sameValue(sym ? 1 : 2, 1, "`sym ? 1 : 2` is `1`"); +assert.sameValue(!sym ? 1 : 2, 2, "`!sym ? 1 : 2` is `2`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/tco-cond-strict.js b/js/src/tests/test262/language/expressions/conditional/tco-cond-strict.js new file mode 100644 index 0000000000..0977d097ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/tco-cond-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: Expression 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; + } + return true ? f(n - 1) : 0; +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/conditional/tco-pos-strict.js b/js/src/tests/test262/language/expressions/conditional/tco-pos-strict.js new file mode 100644 index 0000000000..71931daf96 --- /dev/null +++ b/js/src/tests/test262/language/expressions/conditional/tco-pos-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: Expression 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; + } + return false ? 0 : f(n - 1); +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); |