diff --git a/src/spread/default/array.template b/src/spread/default/array.template new file mode 100644 index 0000000000000000000000000000000000000000..f5525ce4ed73bdbc5b37dcf1e1e80d6cc00d06f6 --- /dev/null +++ b/src/spread/default/array.template @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/array/spread- +name: Array initializer +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +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. +---*/ + +var callCount = 0; + +(function(/*{ params }*/) { + /*{ body }*/ + callCount += 1; +}.apply(null, [/*{ args }*/])); + +assert.sameValue(callCount, 1); diff --git a/src/spread/error/array.template b/src/spread/error/array.template new file mode 100644 index 0000000000000000000000000000000000000000..3506aeaa05f6cf32cbd5aa5c8c9da39b979696e0 --- /dev/null +++ b/src/spread/error/array.template @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/array/spread-err- +name: Array initializer +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +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. +---*/ + +assert.throws(/*{ error }*/, function() { + [/*{ args }*/]; +}); diff --git a/src/spread/mult-expr.case b/src/spread/mult-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..3f5fd6c2fd15ab62a6337f8a384153fc34eee090 --- /dev/null +++ b/src/spread/mult-expr.case @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operator applied to AssignmentExpression following other elements +template: default +info: | + 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. +---*/ + +//- setup +var source = [3, 4, 5]; +var target; +//- args +1, 2, ...target = source +//- body +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); diff --git a/src/spread/mult-literal.case b/src/spread/mult-literal.case new file mode 100644 index 0000000000000000000000000000000000000000..a949b590f14e7f62d08ecf1177b6eb53be2303cd --- /dev/null +++ b/src/spread/mult-literal.case @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operator applied to AssignmentExpression following other elements +template: default +info: | + 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. +---*/ + +//- args +5, ...[6, 7, 8], 9 +//- body +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); diff --git a/src/spread/sngl-expr.case b/src/spread/sngl-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..e1c5b85d04a66525ab6303f139b514530780cc88 --- /dev/null +++ b/src/spread/sngl-expr.case @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operator applied to AssignmentExpression as only element +template: default +info: | + 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. +---*/ + +//- setup +var source = [2, 3, 4]; +var target; +//- args +...target = source +//- body +assert.sameValue(arguments.length, 3); +assert.sameValue(arguments[0], 2); +assert.sameValue(arguments[1], 3); +assert.sameValue(arguments[2], 4); +assert.sameValue(target, source); diff --git a/src/spread/sngl-literal.case b/src/spread/sngl-literal.case new file mode 100644 index 0000000000000000000000000000000000000000..1e647fd1802382a1f82c3ce7331b6792fb09c8a1 --- /dev/null +++ b/src/spread/sngl-literal.case @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operator applied to array literal as only element +template: default +info: | + 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. +---*/ + +//- args +...[3, 4, 5] +//- body +assert.sameValue(arguments.length, 3); +assert.sameValue(arguments[0], 3); +assert.sameValue(arguments[1], 4); +assert.sameValue(arguments[2], 5); diff --git a/test/language/expressions/array/spread-err-mult-err-expr-throws.js b/test/language/expressions/array/spread-err-mult-err-expr-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f9bba177f1d5c901c7e1d421b2a03030bd6faacb --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-expr-throws.js @@ -0,0 +1,36 @@ +// 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 +es6id: 12.2.5.2 +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(); }()]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-iter-get-value.js b/test/language/expressions/array/spread-err-mult-err-iter-get-value.js new file mode 100644 index 0000000000000000000000000000000000000000..f0e8996d8d9f9d98e4b24eac765fd68baebb95d1 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-iter-get-value.js @@ -0,0 +1,49 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-itr-get-call.js b/test/language/expressions/array/spread-err-mult-err-itr-get-call.js new file mode 100644 index 0000000000000000000000000000000000000000..e15c34bb2a7a184f4815efaed10ca5b3e5fcd4c7 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-itr-get-call.js @@ -0,0 +1,47 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-itr-get-get.js b/test/language/expressions/array/spread-err-mult-err-itr-get-get.js new file mode 100644 index 0000000000000000000000000000000000000000..2e5db261c343aa1fdb7bb8d3986a6cbb914d3859 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-itr-get-get.js @@ -0,0 +1,48 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-itr-step.js b/test/language/expressions/array/spread-err-mult-err-itr-step.js new file mode 100644 index 0000000000000000000000000000000000000000..160f2dcb505d03ac3a76c6f00c3a52b362f42606 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-itr-step.js @@ -0,0 +1,57 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-itr-value.js b/test/language/expressions/array/spread-err-mult-err-itr-value.js new file mode 100644 index 0000000000000000000000000000000000000000..fc8f107c0e4680d25c38612fe72d73ad0c601e2b --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-itr-value.js @@ -0,0 +1,60 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-unresolvable.js b/test/language/expressions/array/spread-err-mult-err-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..02117291f58436726e274a710cb813e0805b3c00 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-unresolvable.js @@ -0,0 +1,43 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-expr-throws.js b/test/language/expressions/array/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..15c9019e530de30a82982c6f21f6358026cd5998 --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,38 @@ +// 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 +es6id: 12.2.5.2 +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(); }()]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-itr-get-call.js b/test/language/expressions/array/spread-err-sngl-err-itr-get-call.js new file mode 100644 index 0000000000000000000000000000000000000000..21dfd11d6fd0314ba897afc054301f3192ebe71a --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-itr-get-call.js @@ -0,0 +1,48 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-itr-get-get.js b/test/language/expressions/array/spread-err-sngl-err-itr-get-get.js new file mode 100644 index 0000000000000000000000000000000000000000..3bc6e40d83414ae6bccc5ce58ccf22e31156ece1 --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-itr-get-get.js @@ -0,0 +1,49 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-itr-get-value.js b/test/language/expressions/array/spread-err-sngl-err-itr-get-value.js new file mode 100644 index 0000000000000000000000000000000000000000..bc7a1c3f79c4ba5b4c27fb8dd6ac0bc895f3fc9c --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-itr-get-value.js @@ -0,0 +1,48 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-itr-step.js b/test/language/expressions/array/spread-err-sngl-err-itr-step.js new file mode 100644 index 0000000000000000000000000000000000000000..406d67c7d01c61e2def0d523ec0742b37b94fa06 --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-itr-step.js @@ -0,0 +1,61 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-itr-value.js b/test/language/expressions/array/spread-err-sngl-err-itr-value.js new file mode 100644 index 0000000000000000000000000000000000000000..8a6628f8f74c8883b196e9d2c0b39119d67cdd8b --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-itr-value.js @@ -0,0 +1,67 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-unresolvable.js b/test/language/expressions/array/spread-err-sngl-err-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..2d82c900fde960c71c4614fd5d4680bde1261d64 --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-unresolvable.js @@ -0,0 +1,44 @@ +// 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 +es6id: 12.2.5.2 +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]; +}); diff --git a/test/language/expressions/array/spread-mult-empty.js b/test/language/expressions/array/spread-mult-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..47afca0b279e3fbafd2772143fd92bc29717581b --- /dev/null +++ b/test/language/expressions/array/spread-mult-empty.js @@ -0,0 +1,48 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-mult-expr.js b/test/language/expressions/array/spread-mult-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..64feb1522b32d3b6c614172df28ef2a5b1c6d4b1 --- /dev/null +++ b/test/language/expressions/array/spread-mult-expr.js @@ -0,0 +1,53 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-mult-iter.js b/test/language/expressions/array/spread-mult-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..96e1e12e77d24e15d8cbfc3a0e22742ba765531b --- /dev/null +++ b/test/language/expressions/array/spread-mult-iter.js @@ -0,0 +1,65 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-mult-literal.js b/test/language/expressions/array/spread-mult-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..c77d85aa6f0dae3cb6aa90d22ea063d722598aa1 --- /dev/null +++ b/test/language/expressions/array/spread-mult-literal.js @@ -0,0 +1,50 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-sngl-empty.js b/test/language/expressions/array/spread-sngl-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..a023ef091e3e8a9792fd0efd45f274829c60c3eb --- /dev/null +++ b/test/language/expressions/array/spread-sngl-empty.js @@ -0,0 +1,47 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-sngl-expr.js b/test/language/expressions/array/spread-sngl-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..091daebbb8cb1613b2eb634ac1ffd4087f135b23 --- /dev/null +++ b/test/language/expressions/array/spread-sngl-expr.js @@ -0,0 +1,55 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-sngl-iter.js b/test/language/expressions/array/spread-sngl-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..79c00d64c0aecf0e8b082c3bcc6a378c33ff336b --- /dev/null +++ b/test/language/expressions/array/spread-sngl-iter.js @@ -0,0 +1,62 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/array/spread-sngl-literal.js b/test/language/expressions/array/spread-sngl-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..0374c9d2d192ee7872fd7017907187aec4b89bc5 --- /dev/null +++ b/test/language/expressions/array/spread-sngl-literal.js @@ -0,0 +1,52 @@ +// 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 +es6id: 12.2.5.2 +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); diff --git a/test/language/expressions/call/spread-mult-expr.js b/test/language/expressions/call/spread-mult-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..d15ed52055c5f06bb4a9adaf9fdda8f5d37e5507 --- /dev/null +++ b/test/language/expressions/call/spread-mult-expr.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-expr.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 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; +}(1, 2, ...target = source)); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-literal.js b/test/language/expressions/call/spread-mult-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..87b2a79c487de46da7844c296d8922154f6990c0 --- /dev/null +++ b/test/language/expressions/call/spread-mult-literal.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-literal.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 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; +}(5, ...[6, 7, 8], 9)); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-sngl-expr.js b/test/language/expressions/call/spread-sngl-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..80684f8383bdee6d3eef0146422e50bc76b9981a --- /dev/null +++ b/test/language/expressions/call/spread-sngl-expr.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-expr.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression as only element (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 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; +}(...target = source)); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-sngl-literal.js b/test/language/expressions/call/spread-sngl-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..90ac612086493476944c1fa5b2647eed83886c1f --- /dev/null +++ b/test/language/expressions/call/spread-sngl-literal.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-literal.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to array literal as only element (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 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; +}(...[3, 4, 5])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-expr.js b/test/language/expressions/new/spread-mult-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..a4e038ea78318dafab57933cdf192369c9bdb7ac --- /dev/null +++ b/test/language/expressions/new/spread-mult-expr.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-expr.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 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; + +new 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; +}(1, 2, ...target = source); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-literal.js b/test/language/expressions/new/spread-mult-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..990a6a07fa51cedef510868050ae61ff7a407064 --- /dev/null +++ b/test/language/expressions/new/spread-mult-literal.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-literal.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 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; + +new 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; +}(5, ...[6, 7, 8], 9); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-sngl-expr.js b/test/language/expressions/new/spread-sngl-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..9522722eee53dcb72afb39a8c471ee88dc515a23 --- /dev/null +++ b/test/language/expressions/new/spread-sngl-expr.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-expr.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operator applied to AssignmentExpression as only element (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 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; + +new 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; +}(...target = source); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-sngl-literal.js b/test/language/expressions/new/spread-sngl-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..812e1c4d6752b912322732cd91ceced76e7f1441 --- /dev/null +++ b/test/language/expressions/new/spread-sngl-literal.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-literal.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operator applied to array literal as only element (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 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; + +new function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 3); + assert.sameValue(arguments[1], 4); + assert.sameValue(arguments[2], 5); + callCount += 1; +}(...[3, 4, 5]); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/spread-mult-expr.js b/test/language/expressions/super/spread-mult-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..1eabf849572d75b956e93f7ab9bd4b94d50c6ce8 --- /dev/null +++ b/test/language/expressions/super/spread-mult-expr.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-expr.case +// - src/spread/default/super-call.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 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; + +class Test262ParentClass { + constructor() { + 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; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(1, 2, ...target = source); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/spread-mult-literal.js b/test/language/expressions/super/spread-mult-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..4f2b282e866a0ea085dfc7bfe634398f1262426d --- /dev/null +++ b/test/language/expressions/super/spread-mult-literal.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-literal.case +// - src/spread/default/super-call.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 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; + +class Test262ParentClass { + constructor() { + 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; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(5, ...[6, 7, 8], 9); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/spread-sngl-expr.js b/test/language/expressions/super/spread-sngl-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..e61f79ed1269c74ab25b50e21ebbed750c3ed1d7 --- /dev/null +++ b/test/language/expressions/super/spread-sngl-expr.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-expr.case +// - src/spread/default/super-call.template +/*--- +description: Spread operator applied to AssignmentExpression as only element (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 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; + +class Test262ParentClass { + constructor() { + 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; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(...target = source); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/spread-sngl-literal.js b/test/language/expressions/super/spread-sngl-literal.js new file mode 100644 index 0000000000000000000000000000000000000000..6c0f02b42a54077fa3ccd11bb3b2c30ec31258fd --- /dev/null +++ b/test/language/expressions/super/spread-sngl-literal.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-literal.case +// - src/spread/default/super-call.template +/*--- +description: Spread operator applied to array literal as only element (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 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; + +class Test262ParentClass { + constructor() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 3); + assert.sameValue(arguments[1], 4); + assert.sameValue(arguments[2], 5); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(...[3, 4, 5]); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1);