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/expressions/array | |
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/expressions/array')
54 files changed, 2692 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/array/11.1.4-0.js b/js/src/tests/test262/language/expressions/array/11.1.4-0.js new file mode 100644 index 0000000000..a8541c380a --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/11.1.4-0.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.4-0 +description: > + elements elided at the end of an array do not contribute to its + length +---*/ + + var a = [,]; + +assert.sameValue(a.length, 1, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/11.1.4_4-5-1.js b/js/src/tests/test262/language/expressions/array/11.1.4_4-5-1.js new file mode 100644 index 0000000000..dbb5ec41e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/11.1.4_4-5-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.4; + The production + ElementList : Elisionopt AssignmentExpression + 5.Call the [[DefineOwnProperty]] internal method of array with arguments ToString(firstIndex), the Property Descriptor { [[Value]]: initValue, [[Writable]]: true + , [[Enumerable]]: true, [[Configurable]]: true}, and false. +es5id: 11.1.4_4-5-1 +description: > + Initialize array using ElementList (Elisionopt + AssignmentExpression) when index property (read-only) exists in + Array.prototype (step 5) +---*/ + + Object.defineProperty(Array.prototype, "0", { + value: 100, + writable: false, + configurable: true + }); + var arr = [101]; + +assert(arr.hasOwnProperty("0"), 'arr.hasOwnProperty("0") !== true'); +assert.sameValue(arr[0], 101, 'arr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/11.1.4_5-6-1.js b/js/src/tests/test262/language/expressions/array/11.1.4_5-6-1.js new file mode 100644 index 0000000000..c10e03c7e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/11.1.4_5-6-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.4; + The production + ElementList : ElementList , Elisionopt AssignmentExpression + 6.Call the [[DefineOwnProperty]] internal method of array with arguments ToString(ToUint32((pad+len)) and the Property Descriptor { [[Value]]: initValue + , [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}, and false. +es5id: 11.1.4_5-6-1 +description: > + Initialize array using ElementList (ElementList , Elisionopt + AssignmentExpression) when index property (read-only) exists in + Array.prototype (step 6) +---*/ + + Object.defineProperty(Array.prototype, "1", { + value: 100, + writable: false, + configurable: true + }); + var arr = [101, 12]; + +assert(arr.hasOwnProperty("1"), 'arr.hasOwnProperty("1") !== true'); +assert.sameValue(arr[1], 12, 'arr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.1.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.1.js new file mode 100644 index 0000000000..f0d3b83deb --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ArrayLiteral: [ ]" +es5id: 11.1.4_A1.1 +description: > + Checking various properties of the array defined with expression + "var array = []" +---*/ + +var array = []; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = []; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = []; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = []; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 0) { + throw new Test262Error('#4: var array = []; array.length === 0. Actual: ' + (array.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.2.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.2.js new file mode 100644 index 0000000000..01111b8c26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.2.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ArrayLiteral: [ Elision ]" +es5id: 11.1.4_A1.2 +description: > + Checking various properties the array defined with "var array = + [,,,,,]" +---*/ + +var array = [,,,,,]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [,,,,,]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [,,,,,]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [,,,,,]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [,,,,,]; array.length === 5. Actual: ' + (array.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.3.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.3.js new file mode 100644 index 0000000000..158bbcd25d --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.3.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ArrayLiteral: [ AssignmentExpression ]" +es5id: 11.1.4_A1.3 +description: > + Checking various properteis and contents of the array defined with + "var array = [1,2,3,4,5]" +---*/ + +var array = [1,2,3,4,5]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [1,2,3,4,5]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [1,2,3,4,5]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [1,2,3,4,5]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [1,2,3,4,5]; array.length === 5. Actual: ' + (array.length)); +} + +//CHECK#5 +if (array[0] !== 1) { + throw new Test262Error('#5: var array = [1,2,3,4,5]; array[0] === 1. Actual: ' + (array[0])); +} + +//CHECK#6 +if (array[1] !== 2) { + throw new Test262Error('#6: var array = [1,2,3,4,5]; array[1] === 2. Actual: ' + (array[1])); +} + +//CHECK#7 +if (array[2] !== 3) { + throw new Test262Error('#7: var array = [1,2,3,4,5]; array[2] === 3. Actual: ' + (array[2])); +} + +//CHECK#8 +if (array[3] !== 4) { + throw new Test262Error('#8: var array = [1,2,3,4,5]; array[3] === 4. Actual: ' + (array[3])); +} + +//CHECK#9 +if (array[4] !== 5) { + throw new Test262Error('#9: var array = [1,2,3,4,5]; array[4] === 5. Actual: ' + (array[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.4.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.4.js new file mode 100644 index 0000000000..06298f24dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.4.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ArrayLiteral: [ Elision, AssignmentExpression ]" +es5id: 11.1.4_A1.4 +description: > + Checking various properteis and content of the array defined with + "var array = [,,,1,2]" +---*/ + +var array = [,,,1,2]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [,,,1,2]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [,,,1,2]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [,,,1,2]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [,,,1,2]; array.length === 5. Actual: ' + (array.length)); +} + +//CHECK#5 +if (array[0] !== undefined) { + throw new Test262Error('#5: var array = [,,,1,2]; array[0] === undefined. Actual: ' + (array[0])); +} + +//CHECK#6 +if (array[1] !== undefined) { + throw new Test262Error('#6: var array = [,,,1,2]; array[1] === undefined. Actual: ' + (array[1])); +} + +//CHECK#7 +if (array[2] !== undefined) { + throw new Test262Error('#7: var array = [,,,1,2]; array[2] === undefined. Actual: ' + (array[2])); +} + +//CHECK#8 +if (array[3] !== 1) { + throw new Test262Error('#8: var array = [,,,1,2]; array[3] === 1. Actual: ' + (array[3])); +} + +//CHECK#9 +if (array[4] !== 2) { + throw new Test262Error('#9: var array = [,,,1,2]; array[4] === 2. Actual: ' + (array[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.5.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.5.js new file mode 100644 index 0000000000..2909b08365 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.5.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ArrayLiteral: [ AssignmentExpression, Elision ]" +es5id: 11.1.4_A1.5 +description: > + Checking various properteis and contents of the array defined with + "var array = [4,5,,,,]" +---*/ + +var array = [4,5,,,,]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [4,5,,,,]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [4,5,,,,]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [4,5,,,,]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [4,5,,,,]; array.length === 5. Actual: ' + (array.length)); +} + +//CHECK#5 +if (array[0] !== 4) { + throw new Test262Error('#5: var array = [4,5,,,,]; array[0] === 4. Actual: ' + (array[0])); +} + +//CHECK#6 +if (array[1] !== 5) { + throw new Test262Error('#6: var array = [4,5,,,,]; array[1] === 5. Actual: ' + (array[1])); +} + +//CHECK#7 +if (array[2] !== undefined) { + throw new Test262Error('#7: var array = [4,5,,,,]; array[2] === undefined. Actual: ' + (array[2])); +} + +//CHECK#8 +if (array[3] !== undefined) { + throw new Test262Error('#8: var array = [4,5,,,,]; array[3] === undefined. Actual: ' + (array[3])); +} + +//CHECK#9 +if (array[4] !== undefined) { + throw new Test262Error('#9: var array = [4,5,,,,]; array[4] === undefined. Actual: ' + (array[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.6.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.6.js new file mode 100644 index 0000000000..32be59534d --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.6.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ArrayLiteral: [ Elision, AssignmentExpression, + Elision ] +es5id: 11.1.4_A1.6 +description: > + Checking various properteis and contents of the array defined with + "var array = [,,3,,,]" +---*/ + +var array = [,,3,,,]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [,,3,,,]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [,,3,,,]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [,,3,,,]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [,,3,,,]; array.length === 5. Actual: ' + (array.length)); +} + +//CHECK#5 +if (array[0] !== undefined) { + throw new Test262Error('#5: var array = [,,3,,,]; array[0] === undefined. Actual: ' + (array[0])); +} + +//CHECK#6 +if (array[1] !== undefined) { + throw new Test262Error('#6: var array = [,,3,,,]; array[1] === undefined. Actual: ' + (array[1])); +} + +//CHECK#7 +if (array[2] !== 3) { + throw new Test262Error('#7: var array = [,,3,,,]; array[2] === 3. Actual: ' + (array[2])); +} + +//CHECK#8 +if (array[3] !== undefined) { + throw new Test262Error('#8: var array = [,,3,,,]; array[3] === undefined. Actual: ' + (array[3])); +} + +//CHECK#9 +if (array[4] !== undefined) { + throw new Test262Error('#9: var array = [,,3,,,]; array[4] === undefined. Actual: ' + (array[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A1.7.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.7.js new file mode 100644 index 0000000000..46c51c2d1b --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A1.7.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ArrayLiteral: [ AssignmentExpression, Elision, + AssignmentExpression ] +es5id: 11.1.4_A1.7 +description: > + Checking various properteis and contents of the array defined with + "var array = [1,2,,4,5]" +---*/ + +var array = [1,2,,4,5]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [1,2,,4,5]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [1,2,,4,5]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [1,2,,4,5]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 5) { + throw new Test262Error('#4: var array = [1,2,,4,5]; array.length === 5. Actual: ' + (array.length)); +} + +//CHECK#5 +if (array[0] !== 1) { + throw new Test262Error('#5: var array = [1,2,,4,5]; array[0] === 1. Actual: ' + (array[0])); +} + +//CHECK#6 +if (array[1] !== 2) { + throw new Test262Error('#6: var array = [1,2,,4,5]; array[1] === 2. Actual: ' + (array[1])); +} + +//CHECK#7 +if (array[2] !== undefined) { + throw new Test262Error('#7: var array = [1,2,,4,5]; array[2] === undefined. Actual: ' + (array[2])); +} + +//CHECK#8 +if (array[3] !== 4) { + throw new Test262Error('#8: var array = [1,2,,4,5]; array[3] === 4. Actual: ' + (array[3])); +} + +//CHECK#9 +if (array[4] !== 5) { + throw new Test262Error('#9: var array = [1,2,,4,5]; array[4] === 5. Actual: ' + (array[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/S11.1.4_A2.js b/js/src/tests/test262/language/expressions/array/S11.1.4_A2.js new file mode 100644 index 0000000000..652f88c69c --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/S11.1.4_A2.js @@ -0,0 +1,130 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Create multi dimensional array +es5id: 11.1.4_A2 +description: > + Checking various properteis and contents of the arrya defined with + "var array = [[1,2], [3], []]" +---*/ + +var array = [[1,2], [3], []]; + +//CHECK#1 +if (typeof array !== "object") { + throw new Test262Error('#1: var array = [[1,2], [3], []]; typeof array === "object". Actual: ' + (typeof array)); +} + +//CHECK#2 +if (array instanceof Array !== true) { + throw new Test262Error('#2: var array = [[1,2], [3], []]; array instanceof Array === true'); +} + +//CHECK#3 +if (array.toString !== Array.prototype.toString) { + throw new Test262Error('#3: var array = [[1,2], [3], []]; array.toString === Array.prototype.toString. Actual: ' + (array.toString)); +} + +//CHECK#4 +if (array.length !== 3) { + throw new Test262Error('#4: var array = [[1,2], [3], []]; array.length === 3. Actual: ' + (array.length)); +} + +var subarray = array[0]; + +//CHECK#5 +if (typeof subarray !== "object") { + throw new Test262Error('#5: var array = [[1,2], [3], []]; var subarray = array[0]; typeof subarray === "object". Actual: ' + (typeof subarray)); +} + +//CHECK#6 +if (subarray instanceof Array !== true) { + throw new Test262Error('#6: var array = [[1,2], [3], []]; var subarray = array[0]; subarray instanceof Array === true'); +} + +//CHECK#7 +if (subarray.toString !== Array.prototype.toString) { + throw new Test262Error('#7: var array = [[1,2], [3], []]; var subarray = array[0]; subarray.toString === Array.prototype.toString. Actual: ' + (subarray.toString)); +} + +//CHECK#8 +if (subarray.length !== 2) { + throw new Test262Error('#8: var array = [[1,2], [3], []]; var subarray = array[0]; subarray.length === 2. Actual: ' + (subarray.length)); +} + +//CHECK#9 +if (subarray[0] !== 1) { + throw new Test262Error('#9: var array = [[1,2], [3], []]; var subarray = array[0]; subarray[0] === 1. Actual: ' + (subarray[0])); +} + +//CHECK#10 +if (subarray[1] !== 2) { + throw new Test262Error('#10: var array = [[1,2], [3], []]; var subarray = array[1]; subarray[1] === 2. Actual: ' + (subarray[1])); +} + +var subarray = array[1]; + +//CHECK#11 +if (typeof subarray !== "object") { +throw new Test262Error('#11: var array = [[1,2], [3], []]; var subarray = array[1]; typeof subarray === "object". Actual: ' + (typeof subarray)); +} + +//CHECK#12 +if (subarray instanceof Array !== true) { +throw new Test262Error('#12: var array = [[1,2], [3], []]; var subarray = array[1]; subarray instanceof Array === true'); +} + +//CHECK#13 +if (subarray.toString !== Array.prototype.toString) { +throw new Test262Error('#13: var array = [[1,2], [3], []]; var subarray = array[1]; subarray.toString === Array.prototype.toString. Actual: ' + (subarray.toString)); +} + +//CHECK#14 +if (subarray.length !== 1) { +throw new Test262Error('#14: var array = [[1,2], [3], []]; var subarray = array[1]; subarray.length === 1. Actual: ' + (subarray.length)); +} + +//CHECK#15 +if (subarray[0] !== 3) { +throw new Test262Error('#15: var array = [[1,2], [3], []]; var subarray = array[1]; subarray[0] === 3. Actual: ' + (subarray[0])); +} + +var subarray = array[2]; + +//CHECK#16 +if (typeof subarray !== "object") { +throw new Test262Error('#16: var array = [[1,2], [3], []]; var subarray = array[2]; typeof subarray === "object". Actual: ' + (typeof subarray)); +} + +//CHECK#17 +if (subarray instanceof Array !== true) { +throw new Test262Error('#17: var array = [[1,2], [3], []]; var subarray = array[2]; subarray instanceof Array === true'); +} + +//CHECK#18 +if (subarray.toString !== Array.prototype.toString) { +throw new Test262Error('#18: var array = [[1,2], [3], []]; var subarray = array[2]; subarray.toString === Array.prototype.toString. Actual: ' + (subarray.toString)); +} + +//CHECK#19 +if (subarray.length !== 0) { +throw new Test262Error('#19: var array = [[1,2], [3], []]; var subarray = array[2]; subarray.length === 0. Actual: ' + (subarray.length)); +} + +//CHECK#20 +if (array[0][0] !== 1) { + throw new Test262Error('#20: var array = [[1,2], [3], []]; array[0][0] === 1. Actual: ' + (array[0][0])); +} + +//CHECK#21 +if (array[0][1] !== 2) { + throw new Test262Error('#21: var array = [[1,2], [3], []]; array[0][1] === 2. Actual: ' + (array[0][1])); +} + +//CHECK#22 +if (array[1][0] !== 3) { + throw new Test262Error('#722: var array = [[1,2], [3], []]; array[1][0] === 3. Actual: ' + (array[1][0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/browser.js b/js/src/tests/test262/language/expressions/array/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/browser.js diff --git a/js/src/tests/test262/language/expressions/array/shell.js b/js/src/tests/test262/language/expressions/array/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/shell.js diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-expr-throws.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-expr-throws.js new file mode 100644 index 0000000000..deaf9c43dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-expr-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-expr-throws.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when evaluation throws (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [generators] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + +---*/ + +assert.throws(Test262Error, function() { + [0, ...function*() { throw new Test262Error(); }()]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-iter-get-value.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-iter-get-value.js new file mode 100644 index 0000000000..0867a9fa27 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-iter-get-value.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-iter-get-value.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator function return value) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 2. Let iterator be ? Call(method, obj). + 3. If Type(iterator) is not Object, throw a TypeError exception. +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + return null; + } +}); + +assert.throws(TypeError, function() { + [0, ...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-call.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-call.js new file mode 100644 index 0000000000..d8543c3fa2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-call.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-get-call.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator function invocation) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 3. Let iterator be Call(method,obj). + 4. ReturnIfAbrupt(iterator). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [0, ...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-get.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-get.js new file mode 100644 index 0000000000..f80cc68d13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-get-get.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-get-get.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator property access) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + 1. If method was not passed, then + a. Let method be ? GetMethod(obj, @@iterator). +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [0, ...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-step.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-step.js new file mode 100644 index 0000000000..f55ade0a5e --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-step.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-step.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when IteratorStep fails (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.5 IteratorStep ( iterator ) + + 1. Let result be IteratorNext(iterator). + 2. ReturnIfAbrupt(result). + + 7.4.2 IteratorNext ( iterator, value ) + + 1. If value was not passed, then + a. Let result be Invoke(iterator, "next", « »). + [...] + 3. ReturnIfAbrupt(result). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + [0, ...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-value.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-value.js new file mode 100644 index 0000000000..cde32ee06a --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-itr-value.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-value.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when IteratorValue fails (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.4 IteratorValue ( iterResult ) + + 1. Assert: Type(iterResult) is Object. + 2. Return Get(iterResult, "value"). + + 7.3.1 Get (O, P) + + [...] + 3. Return O.[[Get]](P, O). +---*/ +var iter = {}; +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + [0, ...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-obj-unresolvable.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..3111abca28 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + [{a: 0, ...unresolvableReference}]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-mult-err-unresolvable.js b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-unresolvable.js new file mode 100644 index 0000000000..34348cce7d --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-mult-err-unresolvable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Spread operator following other arguments when reference is unresolvable (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + [0, ...unresolvableReference]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-expr-throws.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000..99dd2cd60e --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-expr-throws.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when evaluation throws (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [generators] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(Test262Error, function() { + [...function*() { throw new Test262Error(); }()]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-call.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-call.js new file mode 100644 index 0000000000..c10deb08ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-call.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-call.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator function invocation) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 3. Let iterator be Call(method,obj). + 4. ReturnIfAbrupt(iterator). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-get.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-get.js new file mode 100644 index 0000000000..82e463fe16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-get.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-get.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator property access) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + 1. If method was not passed, then + a. Let method be ? GetMethod(obj, @@iterator). +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-value.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-value.js new file mode 100644 index 0000000000..a6933c639b --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-get-value.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-value.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator function return value) (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 2. Let iterator be ? Call(method, obj). + 3. If Type(iterator) is not Object, throw a TypeError exception. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return null; +}; + +assert.throws(TypeError, function() { + [...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-step.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-step.js new file mode 100644 index 0000000000..9f77be3502 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-step.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-step.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when IteratorStep fails (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + + 7.4.5 IteratorStep ( iterator ) + + 1. Let result be IteratorNext(iterator). + 2. ReturnIfAbrupt(result). + + 7.4.2 IteratorNext ( iterator, value ) + + 1. If value was not passed, then + a. Let result be Invoke(iterator, "next", « »). + [...] + 3. ReturnIfAbrupt(result). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + [...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-value.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-value.js new file mode 100644 index 0000000000..3970e6f59d --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-itr-value.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-value.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when IteratorValue fails (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + + 7.4.4 IteratorValue ( iterResult ) + + 1. Assert: Type(iterResult) is Object. + 2. Return Get(iterResult, "value"). + + 7.3.1 Get (O, P) + + [...] + 3. Return O.[[Get]](P, O). +---*/ +var iter = {}; +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + [...iter]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..d089e0127b --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + [{...unresolvableReference}]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-unresolvable.js b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-unresolvable.js new file mode 100644 index 0000000000..f796a010f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-err-sngl-err-unresolvable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Spread operator applied to the only argument when reference is unresolvable (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + [...unresolvableReference]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-empty.js b/js/src/tests/test262/language/expressions/array/spread-mult-empty.js new file mode 100644 index 0000000000..58bfdf99d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-empty.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-empty.case +// - src/spread/default/array.template +/*--- +description: Spread operator following other arguments when no iteration occurs (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + callCount += 1; +}.apply(null, [1, 2, 3, ...[]])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-expr.js b/js/src/tests/test262/language/expressions/array/spread-mult-expr.js new file mode 100644 index 0000000000..6d6de57fbd --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-expr.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-expr.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ +var source = [3, 4, 5]; +var target; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + assert.sameValue(arguments[3], 4); + assert.sameValue(arguments[4], 5); + assert.sameValue(target, source); + callCount += 1; +}.apply(null, [1, 2, ...target = source])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-iter.js b/js/src/tests/test262/language/expressions/array/spread-mult-iter.js new file mode 100644 index 0000000000..58bf244d25 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-iter.case +// - src/spread/default/array.template +/*--- +description: Spread operator following other arguments with a valid iterator (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var nextCount = 3; + return { + next: function() { + nextCount += 1; + return { done: nextCount === 6, value: nextCount }; + } + }; +}; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + assert.sameValue(arguments[3], 4); + assert.sameValue(arguments[4], 5); + callCount += 1; +}.apply(null, [1, 2, 3, ...iter])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-literal.js b/js/src/tests/test262/language/expressions/array/spread-mult-literal.js new file mode 100644 index 0000000000..99200683ca --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-literal.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-literal.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 5); + assert.sameValue(arguments[1], 6); + assert.sameValue(arguments[2], 7); + assert.sameValue(arguments[3], 8); + assert.sameValue(arguments[4], 9); + callCount += 1; +}.apply(null, [5, ...[6, 7, 8], 9])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-obj-ident.js b/js/src/tests/test262/language/expressions/array/spread-mult-obj-ident.js new file mode 100644 index 0000000000..376867e5d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-obj-ident.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 4); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(obj, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + + verifyProperty(obj, "c", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "d", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-obj-null.js b/js/src/tests/test262/language/expressions/array/spread-mult-obj-null.js new file mode 100644 index 0000000000..89b71fb411 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-obj-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with null value (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...null}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-mult-obj-undefined.js b/js/src/tests/test262/language/expressions/array/spread-mult-obj-undefined.js new file mode 100644 index 0000000000..06afb0eb3d --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-mult-obj-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with undefined (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...undefined}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-getter-descriptor.js b/js/src/tests/test262/language/expressions/array/spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..565807388e --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-getter-descriptor.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/array.template +/*--- +description: Spread operation with getter results in data property descriptor (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 42 + }); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-getter-init.js b/js/src/tests/test262/language/expressions/array/spread-obj-getter-init.js new file mode 100644 index 0000000000..d3d196353e --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-getter-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/array.template +/*--- +description: Getter in object literal is not evaluated (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o, get c() { executedGetter = true; }}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js b/js/src/tests/test262/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..c7e5cdb8df --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/array.template +/*--- +description: Getter manipulates outter object before it's spread operation (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...cthulhu, ...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread-getter.js b/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..717990ed84 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread-getter.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/array.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5, a: 42, ...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread.js b/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread.js new file mode 100644 index 0000000000..fbeace4e76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-mult-spread.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/array.template +/*--- +description: Multiple Object Spread operation (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; +}.apply(null, [{...o, ...o2}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-null.js b/js/src/tests/test262/language/expressions/array/spread-obj-null.js new file mode 100644 index 0000000000..ae106cfd5c --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/array.template +/*--- +description: Null Object Spread is ignored (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...null}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-override-immutable.js b/js/src/tests/test262/language/expressions/array/spread-obj-override-immutable.js new file mode 100644 index 0000000000..3a97d624d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-override-immutable.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/array.template +/*--- +description: Object Spread overriding immutable properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount += 1; +}.apply(null, [{...o, a: 3}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-overrides-prev-properties.js b/js/src/tests/test262/language/expressions/array/spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..a7da2822d7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-overrides-prev-properties.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/array.template +/*--- +description: Object Spread properties overrides previous definitions (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; +}.apply(null, [{a: 1, b: 7, ...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/array/spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..e064545086 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-skip-non-enumerable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/array.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-spread-order.js b/js/src/tests/test262/language/expressions/array/spread-obj-spread-order.js new file mode 100644 index 0000000000..3e15329cfb --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-spread-order.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/array.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol, object-spread] +flags: [generated] +includes: [compareArray.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var calls = []; +var o = { get z() { calls.push('z') }, get a() { calls.push('a') } }; +Object.defineProperty(o, 1, { get: () => { calls.push(1) }, enumerable: true }); +Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)") }, enumerable: true }); + + +var callCount = 0; + +(function(obj) { + assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-symbol-property.js b/js/src/tests/test262/language/expressions/array/spread-obj-symbol-property.js new file mode 100644 index 0000000000..2d675ed5c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-symbol-property.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/array.template +/*--- +description: Spread operation where source object contains Symbol properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol, object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj[symbol], 1); + assert(Object.prototype.hasOwnProperty.call(obj, symbol), "symbol is an own property"); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-undefined.js b/js/src/tests/test262/language/expressions/array/spread-obj-undefined.js new file mode 100644 index 0000000000..36485e9b93 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-undefined.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/array.template +/*--- +description: Undefined Object Spread is ignored (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...undefined}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-obj-with-overrides.js b/js/src/tests/test262/language/expressions/array/spread-obj-with-overrides.js new file mode 100644 index 0000000000..9ffb6bd799 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-obj-with-overrides.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/array.template +/*--- +description: Object Spread properties being overriden (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol, object-spread] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; +}.apply(null, [{...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-sngl-empty.js b/js/src/tests/test262/language/expressions/array/spread-sngl-empty.js new file mode 100644 index 0000000000..13871d8b11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-sngl-empty.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-empty.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to the only argument when no iteration occurs (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + [...] +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 0); + callCount += 1; +}.apply(null, [...[]])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-sngl-expr.js b/js/src/tests/test262/language/expressions/array/spread-sngl-expr.js new file mode 100644 index 0000000000..1eda282be1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-sngl-expr.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-expr.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to AssignmentExpression as only element (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var source = [2, 3, 4]; +var target; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 2); + assert.sameValue(arguments[1], 3); + assert.sameValue(arguments[2], 4); + assert.sameValue(target, source); + callCount += 1; +}.apply(null, [...target = source])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-sngl-iter.js b/js/src/tests/test262/language/expressions/array/spread-sngl-iter.js new file mode 100644 index 0000000000..9a2aa19b94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-sngl-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-iter.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to the only argument with a valid iterator (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [Symbol.iterator] +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var nextCount = 0; + return { + next: function() { + nextCount += 1; + return { done: nextCount === 3, value: nextCount }; + } + }; +}; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 2); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + callCount += 1; +}.apply(null, [...iter])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-sngl-literal.js b/js/src/tests/test262/language/expressions/array/spread-sngl-literal.js new file mode 100644 index 0000000000..68151e80a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-sngl-literal.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-literal.case +// - src/spread/default/array.template +/*--- +description: Spread operator applied to array literal as only element (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 3); + assert.sameValue(arguments[1], 4); + assert.sameValue(arguments[2], 5); + callCount += 1; +}.apply(null, [...[3, 4, 5]])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/array/spread-sngl-obj-ident.js b/js/src/tests/test262/language/expressions/array/spread-sngl-obj-ident.js new file mode 100644 index 0000000000..584b6937d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/array/spread-sngl-obj-ident.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator without other arguments (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 2); + + verifyProperty(obj, "c", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "d", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); |