diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/postfix-increment')
40 files changed, 1179 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-1gs-strict.js b/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-1gs-strict.js new file mode 100644 index 0000000000..775c2f6945 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-1gs-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.3.1-2-1gs +description: > + Strict Mode - SyntaxError is throw if the identifier arguments + appear as a PostfixExpression(arguments++) +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +arguments++; diff --git a/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-3.js b/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-3.js new file mode 100644 index 0000000000..3b50e26e51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/11.3.1-2-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.3.1-2-3-s +description: > + SyntaxError is not thrown if the identifier 'arguments[...]' appears as a + PostfixExpression(arguments++) +---*/ + +function testcase() { + arguments[1] = 7; + arguments[1]++; + assert.sameValue(arguments[1], 8, 'arguments[1]'); + } +testcase(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.1_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.1_T1.js new file mode 100644 index 0000000000..73cd704ba0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.1_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ uses GetValue and PutValue +es5id: 11.3.1_A2.1_T1 +description: Type(x) is Reference and GetBase(x) is not null +---*/ + +//CHECK#1 +var x = 1; +var y = x++; +if (y !== 1) { + throw new Test262Error('#1: var x = 1; var y = x++; y === 1. Actual: ' + (y)); +} else { + if (x !== 1 + 1) { + throw new Test262Error('#1: var x = 1; var y = x++; x === 1 + 1. Actual: ' + (x)); + } +} + +//CHECK#2 +this.x = 1; +var y = this.x++; +if (y !== 1) { + throw new Test262Error('#2: this.x = 1; var y = this.x++; y === 1. Actual: ' + (y)); +} else { + if (this.x !== 1 + 1) { + throw new Test262Error('#2: this.x = 1; var y = this.x++; this.x === 1 + 1. Actual: ' + (this.x)); + } +} + +//CHECK#3 +var object = new Object(); +object.prop = 1; +var y = object.prop++; +if (y !== 1) { + throw new Test262Error('#3: var object = new Object(); object.prop = 1; var y = object.prop++; y === 1. Actual: ' + (y)); +} else { + if (this.x !== 1 + 1) { + throw new Test262Error('#3: var object = new Object(); object.prop = 1; var y = object.prop++; object.prop === 1 + 1. Actual: ' + (object.prop)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.1_T2.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.1_T2.js new file mode 100644 index 0000000000..42e508fb5e --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_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++ uses GetValue and PutValue +es5id: 11.3.1_A2.1_T2 +description: If GetBase(x) is null, throw ReferenceError +---*/ + +//CHECK#1 +try { + x++; + throw new Test262Error('#1.1: x++ throw ReferenceError. Actual: ' + (x++)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: x++ throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.2_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.2_T1.js new file mode 100644 index 0000000000..5b4b38c802 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A2.2_T1.js @@ -0,0 +1,110 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ uses [[Default Value]] +es5id: 11.3.1_A2.2_T1 +description: If Type(value) is Object, evaluate ToPrimitive(value, Number) +---*/ + +//CHECK#1 +var object = {valueOf: function() {return 1}}; +var y = object++; +if (y !== 1) { + throw new Test262Error('#1: var object = {valueOf: function() {return 1}}; var y = object++; y === 1. Actual: ' + (y)); +} else { + if (object !== 1 + 1) { + throw new Test262Error('#1: var object = {valueOf: function() {return 1}}; object++; object === 1 + 1. Actual: ' + (object)); + } +} + +//CHECK#2 +var object = {valueOf: function() {return 1}, toString: function() {return 0}}; +var y = object++; +if (y !== 1) { + throw new Test262Error('#2: var object = {valueOf: function() {return 1}, toString: function() {return 0}}; var y = object++; y === 1. Actual: ' + (y)); +} else { + if (object !== 1 + 1) { + throw new Test262Error('#2: var object = {valueOf: function() {return 1}, toString: function() {return 0}}; object++; object === 1 + 1. Actual: ' + (object)); + } +} + +//CHECK#3 +var object = {valueOf: function() {return 1}, toString: function() {return {}}}; +var y = object++; +if (y !== 1) { + throw new Test262Error('#3: var object = {valueOf: function() {return 1}, toString: function() {return {}}}; var y = object++; y === 1. Actual: ' + (y)); +} else { + if (object !== 1 + 1) { + throw new Test262Error('#3: var object = {valueOf: function() {return 1}, toString: function() {return {}}}; object++; object === 1 + 1. Actual: ' + (object)); + } +} + +//CHECK#4 +try { + var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; + var y = object++; + if (y !== 1) { + throw new Test262Error('#4.1: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; var y = object++; y === 1. Actual: ' + (y)); + } else { + if (object !== 1 + 1) { + throw new Test262Error('#4.2: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; object++; object === 1 + 1. Actual: ' + (object)); + } + } +} +catch (e) { + if (e === "error") { + throw new Test262Error('#4.3: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; var y = object++; y not throw "error"'); + } else { + throw new Test262Error('#4.4: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; var y = object++; y not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = {toString: function() {return 1}}; +var y = object++; +if (y !== 1) { + throw new Test262Error('#5.1: var object = {toString: function() {return 1}}; var y = object++; y === 1. Actual: ' + (y)); +} else { + if (object !== 1 + 1) { + throw new Test262Error('#5.2: var object = {toString: function() {return 1}}; object++; object === 1 + 1. Actual: ' + (object)); + } +} + + +//CHECK#6 +var object = {valueOf: function() {return {}}, toString: function() {return 1}} +var y = object++; +if (y !== 1) { + throw new Test262Error('#6.1: var object = {valueOf: function() {return {}}, toString: function() {return 1}}; var y = object++; y === 1. Actual: ' + (y)); +} else { + if (object !== 1 + 1) { + throw new Test262Error('#6.2: var object = {valueOf: function() {return {}}, toString: function() {return 1}}; object++; object === 1 + 1. Actual: ' + (object)); + } +} + +//CHECK#7 +try { + var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; + var y = object++; + throw new Test262Error('#7.1: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object++ throw "error". Actual: ' + (y)); +} +catch (e) { + if (e !== "error") { + throw new Test262Error('#7.2: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object++ throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = {valueOf: function() {return {}}, toString: function() {return {}}}; + var y = object++; + throw new Test262Error('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object++ throw TypeError. Actual: ' + (y)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object++ throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T1.js new file mode 100644 index 0000000000..53ba4ca4ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns x = ToNumber(x) + 1 +es5id: 11.3.1_A3_T1 +description: Type(x) is boolean primitive or Boolean object +---*/ + +//CHECK#1 +var x = false; +x++; +if (x !== 0 + 1) { + throw new Test262Error('#1: var x = false; x++; x === 0 + 1. Actual: ' + (x)); +} + +//CHECK#2 +var x = new Boolean(true); +x++; +if (x !== 1 + 1) { + throw new Test262Error('#2: var x = new Boolean(true); x++; x === 1 + 1. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T2.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T2.js new file mode 100644 index 0000000000..3cff471e1a --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns x = ToNumber(x) + 1 +es5id: 11.3.1_A3_T2 +description: Type(x) is number primitive or Number object +---*/ + +//CHECK#1 +var x = 0.1; +x++; +if (x !== 0.1 + 1) { + throw new Test262Error('#1: var x = 0.1; x++; x === 0.1 + 1. Actual: ' + (x)); +} + +//CHECK#2 +var x = new Number(-1.1); +x++; +if (x !== -1.1 + 1) { + throw new Test262Error('#2: var x = new Number(-1.1); x++; x === -1.1 + 1. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T3.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T3.js new file mode 100644 index 0000000000..74b835e9fc --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T3.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns x = ToNumber(x) + 1 +es5id: 11.3.1_A3_T3 +description: Type(x) is string primitive or String object +---*/ + +//CHECK#1 +var x = "1"; +x++; +if (x !== 1 + 1) { + throw new Test262Error('#1: var x = "1"; x++; x === 1 + 1. Actual: ' + (x)); +} + +//CHECK#2 +var x = "x"; +x++; +if (isNaN(x) !== true) { + throw new Test262Error('#2: var x = "x"; x++; x === Not-a-Number. Actual: ' + (x)); +} + +//CHECK#3 +var x = new Number("-1"); +x++; +if (x !== -1 + 1) { + throw new Test262Error('#3: var x = new String("-1"); x++; x === -1 + 1. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T4.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T4.js new file mode 100644 index 0000000000..88015215b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns x = ToNumber(x) + 1 +es5id: 11.3.1_A3_T4 +description: Type(x) is undefined or null +---*/ + +//CHECK#1 +var x; +x++; +if (isNaN(x) !== true) { + throw new Test262Error('#1: var x; x++; x === Not-a-Number. Actual: ' + (x)); +} + +//CHECK#2 +var x = null; +x++; +if (x !== 1) { + throw new Test262Error('#2: var x = null; x++; x === 1. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T5.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T5.js new file mode 100644 index 0000000000..70b6c35157 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A3_T5.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns x = ToNumber(x) + 1 +es5id: 11.3.1_A3_T5 +description: Type(x) is Object object or Function object +---*/ + +//CHECK#1 +var x = {}; +x++; +if (isNaN(x) !== true) { + throw new Test262Error('#1: var x = {}; x++; x === Not-a-Number. Actual: ' + (x)); +} + +//CHECK#2 +var x = function(){return 1}; +x++; +if (isNaN(x) !== true) { + throw new Test262Error('#2: var x = function(){return 1}; x++; x === Not-a-Number. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T1.js new file mode 100644 index 0000000000..055a91a9e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns ToNumber(x) +es5id: 11.3.1_A4_T1 +description: Type(x) is boolean primitive or Boolean object +---*/ + +//CHECK#1 +var x = false; +var y = x++; +if (y !== 0) { + throw new Test262Error('#1: var x = false; var y = x++; y === 0. Actual: ' + (y)); +} + +//CHECK#2 +var x = new Boolean(true); +var y = x++; +if (y !== 1) { + throw new Test262Error('#2: var x = new Boolean(true); var y = x++; y === 1. Actual: ' + (y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T2.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T2.js new file mode 100644 index 0000000000..c078b3d2ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns ToNumber(x) +es5id: 11.3.1_A4_T2 +description: Type(x) is number primitive or Number object +---*/ + +//CHECK#1 +var x = -0.1; +var y = x++; +if (y !== -0.1) { + throw new Test262Error('#1: var x = -0.1; var y = x++; y === -0.1. Actual: ' + (y)); +} + +//CHECK#2 +var x = new Number(1.1); +var y = x++; +if (y !== 1.1) { + throw new Test262Error('#2: var x = new Number(1.1); var y = x++; y === 1.1. Actual: ' + (y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T3.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T3.js new file mode 100644 index 0000000000..10738f07f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T3.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns ToNumber(x) +es5id: 11.3.1_A4_T3 +description: Type(x) is string primitive or String object +---*/ + +//CHECK#1 +var x = "1"; +var y = x++; +if (y !== 1) { + throw new Test262Error('#1: var x = "1"; var y = x++; y === 1. Actual: ' + (y)); +} + +//CHECK#2 +var x = "x"; +var y = x++; +if (isNaN(y) !== true) { + throw new Test262Error('#2: var x = "x"; var y = x++; y === Not-a-Number. Actual: ' + (y)); +} + +//CHECK#3 +var x = new String("-1"); +var y = x++; +if (y !== -1) { + throw new Test262Error('#3: var x = new String("-1"); var y = x++; y === -1. Actual: ' + (y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T4.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T4.js new file mode 100644 index 0000000000..251c7844f3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns ToNumber(x) +es5id: 11.3.1_A4_T4 +description: Type(x) is undefined or null +---*/ + +//CHECK#1 +var x; +var y = x++; +if (isNaN(y) !== true) { + throw new Test262Error('#1: var x; var y = x++; y === Not-a-Number. Actual: ' + (y)); +} + +//CHECK#2 +var x = null; +var y = x++; +if (y !== 0) { + throw new Test262Error('#2: var x = null; var y = x++; y === 0. Actual: ' + (y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T5.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T5.js new file mode 100644 index 0000000000..b85d9ef7ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A4_T5.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ returns ToNumber(x) +es5id: 11.3.1_A4_T5 +description: Type(x) is Object object or Function object +---*/ + +//CHECK#1 +var x = {}; +var y = x++; +if (isNaN(y) !== true) { + throw new Test262Error('#1: var x = {}; var y = x++; y === Not-a-Number. Actual: ' + (y)); +} + +//CHECK#2 +var x = function(){return 1}; +var y = x++; +if (isNaN(y) !== true) { + throw new Test262Error('#2: var x = function(){return 1}; var y = x++; y === Not-a-Number. Actual: ' + (y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T1.js new file mode 100644 index 0000000000..25e9610a15 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T1.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ calls PutValue(lhs, newValue) +es5id: S11.3.1_A5_T1 +description: > + Evaluating LeftHandSideExpression lhs returns Reference type; Reference + base value is an environment record and environment record kind is + object environment record. PutValue(lhs, newValue) uses the initially + created Reference even if the environment binding is no longer present. + Binding in surrounding function environment record is not changed. +flags: [noStrict] +---*/ + +function testFunction() { + var x = 0; + var scope = { + get x() { + delete this.x; + return 2; + } + }; + + with (scope) { + x++; + } + + if (scope.x !== 3) { + throw new Test262Error('#1: scope.x === 3. Actual: ' + (scope.x)); + } + if (x !== 0) { + throw new Test262Error('#2: x === 0. Actual: ' + (x)); + } +} +testFunction(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T2.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T2.js new file mode 100644 index 0000000000..9ec9c15596 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T2.js @@ -0,0 +1,35 @@ +// Copyright (C) 2014 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ calls PutValue(lhs, newValue) +es5id: S11.3.1_A5_T2 +description: > + Evaluating LeftHandSideExpression lhs returns Reference type; Reference + base value is an environment record and environment record kind is + object environment record. PutValue(lhs, newValue) uses the initially + created Reference even if the environment binding is no longer present. + Binding in surrounding global environment record is not changed. +flags: [noStrict] +---*/ + +var x = 0; +var scope = { + get x() { + delete this.x; + return 2; + } +}; + +with (scope) { + x++; +} + +if (scope.x !== 3) { + throw new Test262Error('#1: scope.x === 3. Actual: ' + (scope.x)); +} +if (x !== 0) { + throw new Test262Error('#2: x === 0. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T3.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T3.js new file mode 100644 index 0000000000..be8c8bff58 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A5_T3.js @@ -0,0 +1,39 @@ +// Copyright (C) 2014 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ calls PutValue(lhs, newValue) +es5id: S11.3.1_A5_T3 +description: > + Evaluating LeftHandSideExpression lhs returns Reference type; Reference + base value is an environment record and environment record kind is + object environment record. PutValue(lhs, newValue) uses the initially + created Reference even if the environment binding is no longer present. + Binding in surrounding object environment record is not changed. +flags: [noStrict] +---*/ + +var outerScope = { + x: 0 +}; +var innerScope = { + get x() { + delete this.x; + return 2; + } +}; + +with (outerScope) { + with (innerScope) { + x++; + } +} + +if (innerScope.x !== 3) { + throw new Test262Error('#1: innerScope.x === 3. Actual: ' + (innerScope.x)); +} +if (outerScope.x !== 0) { + throw new Test262Error('#2: outerScope.x === 0. Actual: ' + (outerScope.x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T1.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T1.js new file mode 100644 index 0000000000..a0c5784b6a --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T1.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ evaluates its reference expression once. +description: > + The operand expression is evaluated exactly once. Operand expression is + MemberExpression: base[prop]. base is the null value. +---*/ + +function DummyError() { } + +assert.throws(DummyError, function() { + var base = null; + var prop = function() { + throw new DummyError(); + }; + + base[prop()]++; +}); + +assert.throws(TypeError, function() { + var base = null; + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + + base[prop]++; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T2.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T2.js new file mode 100644 index 0000000000..889bb0c9a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T2.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ evaluates its reference expression once. +description: > + The operand expression is evaluated exactly once. Operand expression is + MemberExpression: base[prop]. base is the undefined value. +---*/ + +function DummyError() { } + +assert.throws(DummyError, function() { + var base = undefined; + var prop = function() { + throw new DummyError(); + }; + + base[prop()]++; +}); + +assert.throws(TypeError, function() { + var base = undefined; + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + + base[prop]++; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T3.js b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T3.js new file mode 100644 index 0000000000..ce2fc1c204 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/S11.3.1_A6_T3.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x++ evaluates its reference expression once. +description: > + The operand expression is evaluated exactly once. Operand expression is + MemberExpression: base[prop]. ToPropertyKey(prop) is not called multiple + times. +---*/ + +var propKeyEvaluated = false; +var base = {}; +var prop = { + toString: function() { + assert(!propKeyEvaluated); + propKeyEvaluated = true; + return 1; + } +}; + +base[prop]++; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/arguments-nostrict.js b/js/src/tests/test262/language/expressions/postfix-increment/arguments-nostrict.js new file mode 100644 index 0000000000..e88aa31940 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/arguments-nostrict.js @@ -0,0 +1,27 @@ +// Copyright (c) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-update-expressions-static-semantics-early-errors +description: > + In non-strict code, "arguments++" does not produce an early error. +info: | + sec-identifiers-static-semantics-assignmenttargettype + + 1. If this IdentifierReference is contained in strict mode code and StringValue of Identifier is "eval" or "arguments", return strict. + 2. Return simple. + + sec-update-expressions-static-semantics-early-errors + + UpdateExpression : LeftHandSideExpression ++ + + It is an early Reference Error if AssignmentTargetType of LeftHandSideExpression is invalid. + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is strict. +flags: [noStrict] +---*/ + +if (false) { + arguments++; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/arguments-strict.js b/js/src/tests/test262/language/expressions/postfix-increment/arguments-strict.js new file mode 100644 index 0000000000..c76d277132 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/arguments-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-assignmenttargettype +description: > + If this IdentifierReference is contained in strict mode code and StringValue of Identifier is "eval" or "arguments", return strict. +info: | + sec-update-expressions-static-semantics-early-errors + + UpdateExpression: LeftHandSideExpression ++ + + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is strict. +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +arguments++; diff --git a/js/src/tests/test262/language/expressions/postfix-increment/bigint.js b/js/src/tests/test262/language/expressions/postfix-increment/bigint.js new file mode 100644 index 0000000000..29308b342a --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/bigint.js @@ -0,0 +1,64 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Postfix increment for references to BigInt values +esid: sec-postfix-increment-operator-runtime-semantics-evaluation +info: | + 1. Let expr be the result of evaluating UnaryExpression. + 2. Let oldValue be ? ToNumeric(? GetValue(expr)). + 3. Let newValue be ? Type(oldvalue)::add(oldValue, Type(oldValue)::unit). + 4. Perform ? PutValue(expr, newValue). + 5. Return oldValue. +features: [BigInt] +---*/ + +var x = 0n; +assert.sameValue(x++, 0n, "var x = 0n; x++ === 0n"); +assert.sameValue(x, 1n, "var x = 0n; x++; x === 1n"); + +var x = -1n; +assert.sameValue(x++, -1n, "var x = -1n; x++ === -1n"); +assert.sameValue(x, 0n, "var x = -1n; x++; x === 0n"); + +var x = 123456n; +assert.sameValue(x++, 123456n, "var x = 123456n; x++ === 123456n"); +assert.sameValue(x, 123457n, "var x = 123456n; x++; x === 123457n"); + +var x = -123457n; +assert.sameValue(x++, -123457n, "var x = -123457n; x++ === -123457n"); +assert.sameValue(x, -123456n, "var x = -123457n; x++; x === -123456n"); + +var x = 0x1fffffffffffff00n; +assert.sameValue(x++, 0x1fffffffffffff00n, "var x = 0x1fffffffffffff00n; x++ === 0x1fffffffffffff00n"); +assert.sameValue(x, 0x1fffffffffffff01n, "var x = 0x1fffffffffffff00n; x++; x === 0x1fffffffffffff01n"); + +var x = -0x1fffffffffffff01n; +assert.sameValue(x++, -0x1fffffffffffff01n, "var x = -0x1fffffffffffff01n; x++ === -0x1fffffffffffff01n"); +assert.sameValue(x, -0x1fffffffffffff00n, "var x = -0x1fffffffffffff01n; x++; x === -0x1fffffffffffff00n"); + +var x = {y:0n}; +assert.sameValue(x.y++, 0n, "var x = {y:0n}; x.y++ === 0n"); +assert.sameValue(x.y, 1n, "var x = {y:0n}; x.y++; x.y === 1n"); + +var x = {y:{z:0n}}; +assert.sameValue(x.y.z++, 0n, "var x = {y:{z:0n}}; x.y.z++ === 0n"); +assert.sameValue(x.y.z, 1n, "var x = {y:{z:0n}}; x.y.z++; x.y.z === 1n"); + +var x = [0n]; +assert.sameValue(x[0]++, 0n, "var x = [0n]; x[0]++ === 0n"); +assert.sameValue(x[0], 1n, "var x = [0n]; x[0]++; x[0] === 1n"); + +var x = [null, [null, null, 0n]]; +assert.sameValue(x[1][2]++, 0n, "var x = [null, [null, null, 0n]]; x[1][2]++ === 0n"); +assert.sameValue(x[1][2], 1n, "var x = [null, [null, null, 0n]]; x[1][2]++; x[1][2] === 1n"); + +var x = {y:[0n]}; +assert.sameValue(x.y[0]++, 0n, "var x = {y:[0n]}; x.y[0]++ === 0n"); +assert.sameValue(x.y[0], 1n, "var x = {y:[0n]}; x.y[0]++; x.y[0] === 1n"); + +var x = [{z:0n}]; +assert.sameValue(x[0].z++, 0n, "var x = [{z:0n}]; x[0].z++ === 0n"); +assert.sameValue(x[0].z, 1n, "var x = [{z:0n}]; x[0].z++; x[0].z === 1n"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/browser.js b/js/src/tests/test262/language/expressions/postfix-increment/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/browser.js diff --git a/js/src/tests/test262/language/expressions/postfix-increment/eval-nostrict.js b/js/src/tests/test262/language/expressions/postfix-increment/eval-nostrict.js new file mode 100644 index 0000000000..a85b061e48 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/eval-nostrict.js @@ -0,0 +1,25 @@ +// Copyright (c) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-update-expressions +description: > + In non-strict code, "eval++" does not produce an early error. +info: | + sec-identifiers-static-semantics-assignmenttargettype + + 1. If this IdentifierReference is contained in strict mode code and StringValue of Identifier is "eval" or "arguments", return strict. + 2. Return simple. + + sec-update-expressions-static-semantics-early-errors + + UpdateExpression : LeftHandSideExpression ++ + + It is an early Reference Error if AssignmentTargetType of LeftHandSideExpression is invalid. + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is strict. +flags: [noStrict] +---*/ + +eval++; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/eval-strict.js b/js/src/tests/test262/language/expressions/postfix-increment/eval-strict.js new file mode 100644 index 0000000000..401e3cd59d --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/eval-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-assignmenttargettype +description: > + If this IdentifierReference is contained in strict mode code and StringValue of Identifier is "eval" or "arguments", return strict. +info: | + sec-update-expressions-static-semantics-early-errors + + UpdateExpression: LeftHandSideExpression ++ + + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is strict. +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +eval++; diff --git a/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-carriage-return.js b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-carriage-return.js new file mode 100644 index 0000000000..2ff9e7a5ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-carriage-return.js @@ -0,0 +1,19 @@ +// |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: Line Terminator between LeftHandSideExpression and "++" is not allowed +es5id: 11.3.1_A1.1_T2 +esid: postfix-increment-operator +description: Carriage Return +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +x +++; +// The preceding line contains an unprintable CARRIAGE RETURN character (U+000D) diff --git a/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-feed.js b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-feed.js new file mode 100644 index 0000000000..f41423cb5b --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-feed.js @@ -0,0 +1,18 @@ +// |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: Line Terminator between LeftHandSideExpression and "++" is not allowed +es5id: 11.3.1_A1.1_T1 +esid: postfix-increment-operator +description: Checking Line Feed +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +x +++; diff --git a/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-separator.js b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-separator.js new file mode 100644 index 0000000000..e9e53b0c2d --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-line-separator.js @@ -0,0 +1,18 @@ +// |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: Line Terminator between LeftHandSideExpression and "++" is not allowed +es5id: 11.3.1_A1.1_T3 +esid: postfix-increment-operator +description: Checking Line Separator +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +x
++; +// The preceding line contains an unprintable LINE SEPARATOR character (U+2028) diff --git a/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-paragraph-separator.js b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-paragraph-separator.js new file mode 100644 index 0000000000..441f1328b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/line-terminator-paragraph-separator.js @@ -0,0 +1,19 @@ +// |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: Line Terminator between LeftHandSideExpression and "++" is not allowed +es5id: 11.3.1_A1.1_T4 +esid: postfix-increment-operator +description: Checking Paragraph separator +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +x
++; +// The preceding line contains an unprintable PARAGRAPH SEPARATOR character +// (U+2029) diff --git a/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue--1.js b/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue--1.js new file mode 100644 index 0000000000..c38e053da1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue--1.js @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object-environment-records-setmutablebinding-n-v-s +description: > + Operator x++ calls PutValue(lhs, newValue) (formerly S11.3.1_A5_T5) +info: | + The concrete Environment Record method SetMutableBinding for object Environment + Records attempts to set the value of the Environment Record's associated binding + object's property whose name is the value of the argument N to the value of argument V. + A property named N normally already exists but if it does not or is not currently writable, + error handling is determined by the value of the Boolean argument S. + + Let stillExists be ? HasProperty(bindings, N). + If stillExists is false and S is true, throw a ReferenceError exception. +flags: [noStrict] +---*/ +var count = 0; +Object.defineProperty(this, "x", { + configurable: true, + get: function() { + delete this.x; + return 2; + } +}); + +(function() { + "use strict"; + assert.throws(ReferenceError, () => { + count++; + x++; + count++; + }); + count++; +})(); + +assert.sameValue(count, 2); +assert(!('x' in this)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue-.js b/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue-.js new file mode 100644 index 0000000000..28684d5998 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue-.js @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object-environment-records-setmutablebinding-n-v-s +description: > + Operator x++ calls PutValue(lhs, newValue) (formerly S11.3.1_A5_T4) +info: | + The concrete Environment Record method SetMutableBinding for object Environment + Records attempts to set the value of the Environment Record's associated binding + object's property whose name is the value of the argument N to the value of argument V. + A property named N normally already exists but if it does not or is not currently writable, + error handling is determined by the value of the Boolean argument S. + + Let stillExists be ? HasProperty(bindings, N). + If stillExists is false and S is true, throw a ReferenceError exception. +flags: [noStrict] +---*/ +var count = 0; +var scope = { + get x() { + delete this.x; + return 2; + } +}; + +with (scope) { + (function() { + "use strict"; + assert.throws(ReferenceError, () => { + count++; + x++; + count++; + }); + count++; + })(); +} + +assert.sameValue(count, 2); +assert(!('x' in scope)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/shell.js b/js/src/tests/test262/language/expressions/postfix-increment/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/shell.js diff --git a/js/src/tests/test262/language/expressions/postfix-increment/target-cover-id.js b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-id.js new file mode 100644 index 0000000000..ad269175bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-id.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. +/*--- +esid: sec-postfix-expressions-static-semantics-early-errors +es6id: 12.4.1 +es5id: 11.1.6_A3_T5 +description: Applied to a "covered" IdentifierReference +info: | + PostfixExpression : + LeftHandSideExpression ++ + LeftHandSideExpression -- + + - It is an early Reference Error if IsValidSimpleAssignmentTarget of + LeftHandSideExpression is false. + + Static Semantics: IsValidSimpleAssignmentTarget + + IdentifierReference : Identifier + + 1. If this IdentifierReference is contained in strict mode code and + StringValue of Identifier is "eval" or "arguments", return false. + 2. Return true. +---*/ + +var y = 1; + +(y)++; +assert.sameValue(y, 2); + +((y))++; +assert.sameValue(y, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/postfix-increment/target-cover-newtarget.js b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-newtarget.js new file mode 100644 index 0000000000..daca101d24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-newtarget.js @@ -0,0 +1,32 @@ +// |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-update-expressions-static-semantics-early-errors +description: Applied to a "covered" new.target +info: | + UpdateExpression : + LeftHandSideExpression ++ + LeftHandSideExpression -- + + - It is an early Syntax Error if AssignmentTargetType of + LeftHandSideExpression is invalid or strict. + + 12.3.1.6 Static Semantics: AssignmentTargetType + + NewTarget: + + new.target + + 1. Return invalid. +negative: + phase: parse + type: SyntaxError +features: [new.target] +---*/ + +$DONOTEVALUATE(); + +function f() { + (new.target)++; +} diff --git a/js/src/tests/test262/language/expressions/postfix-increment/target-cover-yieldexpr.js b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-yieldexpr.js new file mode 100644 index 0000000000..c2514d23e1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/target-cover-yieldexpr.js @@ -0,0 +1,35 @@ +// |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-update-expressions-static-semantics-early-errors +description: Applied to a "covered" YieldExpression +info: | + UpdateExpression : + LeftHandSideExpression ++ + LeftHandSideExpression -- + + - It is an early Syntax Error if AssignmentTargetType of + LeftHandSideExpression is invalid or strict. + + 12.15.3 Static Semantics: AssignmentTargetType + + AssignmentExpression: + YieldExpression + ArrowFunction + AsyncArrowFunction + LeftHandSideExpression = AssignmentExpression + LeftHandSideExpression AssignmentOperator AssignmentExpression + + 1. Return invalid. +features: [generators] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function* g() { + (yield)++; +} diff --git a/js/src/tests/test262/language/expressions/postfix-increment/target-newtarget.js b/js/src/tests/test262/language/expressions/postfix-increment/target-newtarget.js new file mode 100644 index 0000000000..40b67143d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/target-newtarget.js @@ -0,0 +1,32 @@ +// |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-update-expressions-static-semantics-early-errors +description: Applied to new.target +info: | + UpdateExpression : + LeftHandSideExpression ++ + LeftHandSideExpression -- + + - It is an early Syntax Error if AssignmentTargetType of + LeftHandSideExpression is invalid or strict. + + 12.3.1.6 Static Semantics: AssignmentTargetType + + NewTarget: + + new.target + + 1. Return invalid. +negative: + phase: parse + type: SyntaxError +features: [new.target] +---*/ + +$DONOTEVALUATE(); + +function f() { + new.target++; +} diff --git a/js/src/tests/test262/language/expressions/postfix-increment/this.js b/js/src/tests/test262/language/expressions/postfix-increment/this.js new file mode 100644 index 0000000000..1568cf44e6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/this.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2023 Veera Sivarajan. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-update-expressions-static-semantics-early-errors +description: > + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple. (this) +info: | + sec-static-semantics-assignmenttargettype + + PrimaryExpression: this + + Return invalid. + + sec-update-expressions-static-semantics-early-errors + + UpdateExpression: LeftHandSideExpression ++ + + It is an early Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +this++; diff --git a/js/src/tests/test262/language/expressions/postfix-increment/whitespace.js b/js/src/tests/test262/language/expressions/postfix-increment/whitespace.js new file mode 100644 index 0000000000..1987986e73 --- /dev/null +++ b/js/src/tests/test262/language/expressions/postfix-increment/whitespace.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: White Space between LeftHandSideExpression and "++" are allowed +es5id: 11.3.1_A1.2_T1 +esid: postfix-increment-operator +---*/ + +var x = 0; + +assert.sameValue(x ++, 0, 'U+0009 (expression)'); +assert.sameValue(x, 1, 'U+0009 (side effect)'); + +assert.sameValue(x++, 1, 'U+000B (expression)'); +assert.sameValue(x, 2, 'U+000B (side effect)'); + +assert.sameValue(x++, 2, 'U+000C (expression)'); +assert.sameValue(x, 3, 'U+000C (side effect)'); + +assert.sameValue(x ++, 3, 'U+0020 (expression)'); +assert.sameValue(x, 4, 'U+0020 (side effect)'); + +assert.sameValue(x ++, 4, 'U+00A0 (expression)'); +assert.sameValue(x, 5, 'U+00A0 (side effect)'); + +assert.sameValue(x ++, 5, 'U+0009U+000BU+000CU+0020U+00A0 (expression)'); +assert.sameValue(x, 6, 'U+0009U+000BU+000CU+0020U+00A0 (side effect)'); + +reportCompare(0, 0); |