diff --git a/src/dstr-assignment-async-iteration/array-elem-init-assignment.case b/src/dstr-assignment-async-iteration/array-elem-init-assignment.case new file mode 100644 index 0000000000000000000000000000000000000000..d6e17a22f549e93616d542506b569115b2c413ec --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-assignment.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference. +template: default +---*/ + +//- setup +let v2, vNull, vHole, vUndefined, vOob; +//- elems +[v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] +//- vals +[2, null, , undefined] +//- body +assert.sameValue(v2, 2); +assert.sameValue(vNull, null); +assert.sameValue(vHole, 12); +assert.sameValue(vUndefined, 13); +assert.sameValue(vOob, 14); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case b/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..85ec19f4affb747a0001a66493f9f3cf893d9bda --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer should only be evaluated if v is undefined. +template: default +---*/ + +//- setup +let flag1 = false, flag2 = false; +let _; +//- elems +[ _ = flag1 = true, _ = flag2 = true ] +//- vals +[14] +//- body +assert.sameValue(flag1, false); +assert.sameValue(flag2, true); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case new file mode 100644 index 0000000000000000000000000000000000000000..d3cf8df244f96a63c13f4f72eea848a60cd5a270 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ArrowFunction) +template: default +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let arrow; +//- elems +[ arrow = () => {} ] +//- vals +[] +//- body +assert.sameValue(arrow.name, 'arrow'); +verifyNotEnumerable(arrow, 'name'); +verifyNotWritable(arrow, 'name'); +verifyConfigurable(arrow, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case new file mode 100644 index 0000000000000000000000000000000000000000..448124558ad45f47710256eaf4e2f18929fa7c8e --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ClassExpression) +template: default +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xCls, cls, xCls2; +//- elems +[ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] +//- vals +[] +//- body +assert(xCls.name !== 'xCls'); +assert(xCls2.name !== 'xCls2'); + +assert.sameValue(cls.name, 'cls'); +verifyNotEnumerable(cls, 'name'); +verifyNotWritable(cls, 'name'); +verifyConfigurable(cls, 'name'); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case new file mode 100644 index 0000000000000000000000000000000000000000..348a1ced776b6743164c6330056ff2fd25851856 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let xCover, cover; +//- elems +[ xCover = (0, function() {}), cover = (function() {}) ] +//- vals +[] +//- body +assert(xCover.name !== 'xCover'); + +assert.sameValue(cover.name, 'cover'); +verifyNotEnumerable(cover, 'name'); +verifyNotWritable(cover, 'name'); +verifyConfigurable(cover, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case new file mode 100644 index 0000000000000000000000000000000000000000..d6d2d5702ddef88631e3f434e7685c2b4bd219be --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (FunctionExpression) +template: default +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xFnexp, fnexp; +//- elems +[ xFnexp = function x() {}, fnexp = function() {} ] +//- vals +[] +//- body +assert(xFnexp.name !== 'xFnexp'); + +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case new file mode 100644 index 0000000000000000000000000000000000000000..c05ff848f59a7e79e30006e89d87f096889cb9bf --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [generators] +---*/ + +//- setup +let xGen, gen; +//- elems +[ xGen = function* x() {}, gen = function*() {} ] +//- vals +[] +//- body +assert.notSameValue(xGen.name, 'xGen'); + +assert.sameValue(gen.name, 'gen'); +verifyNotEnumerable(gen, 'name'); +verifyNotWritable(gen, 'name'); +verifyConfigurable(gen, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-in.case b/src/dstr-assignment-async-iteration/array-elem-init-in.case new file mode 100644 index 0000000000000000000000000000000000000000..70435eba4fef3a841d4c391b5e7b5c0224a1dffe --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-in.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer in an AssignmentElement may be an `in` expression. +template: default +---*/ + +//- setup +let x; +//- elems +[ x = 'x' in {} ] +//- vals +[] +//- body +assert.sameValue(x, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-let.case b/src/dstr-assignment-async-iteration/array-elem-init-let.case new file mode 100644 index 0000000000000000000000000000000000000000..b25e02e031b1eabb81bb8e8231890b7156ca82a8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-let.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Value retrieval of Initializer obeys `let` semantics. +template: default +es6id: 12.14.5.3 +features: [let] +---*/ + +//- setup +let x; +//- elems +[ x = y ] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); + +let y; + diff --git a/src/dstr-assignment-async-iteration/array-elem-init-order.case b/src/dstr-assignment-async-iteration/array-elem-init-order.case new file mode 100644 index 0000000000000000000000000000000000000000..a11457512627cc3e13d180bc1bcd1364e818c399 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-order.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Initializer values should be assigned in left-to-right order. +template: default +---*/ + +//- setup +let x = 0; +let a, b; +//- elems +[ a = x += 1, b = x *= 2 ] +//- vals +[] +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(x, 2); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case b/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..c5e33b30396e6e33277199f49313637a6b24cf47 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Identifiers that appear as the DestructuringAssignmentTarget in an + AssignmentElement should take on the iterated value corresponding to their + position in the ArrayAssignmentPattern. +template: default +flags: [noStrict] +---*/ + +//- setup +let argument, eval; +//- elems +[arguments = 4, eval = 5] +//- vals +[] +//- body +assert.sameValue(arguments, 4); +assert.sameValue(eval, 5); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..0d3cdfd55a33651ff53f045ee28798ade2643c57 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentElement within a generator function body, it behaves as a + YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let value = []; +let x; +//- elems +[ x = yield ] +//- vals +[] +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 4); + }, $DONE).then($DONE, $DONE); +}, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..559a52fc22cc403eb7293e58ece57f44402e10e7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + outside of a generator function body, it behaves as an IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.4 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[ x = yield ] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..01b1ed2a1f675f293f5cf33f6f8363e416e7ad81 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + outside of a generator function body, it behaves as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 4; +let x; +//- elems +[ x = yield ] +//- vals +[] +//- body +assert.sameValue(x, 4); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case b/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case new file mode 100644 index 0000000000000000000000000000000000000000..06ebf52f86c409ed5758c1a4504a5a2f21433b6b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from GetIterator +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + 1. Let iterator be ? GetIterator(value). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterable = { + [Symbol.iterator]() { + throw new Test262Error(); + } +}; +let _; + +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..3ca0ccc29dc84574531ad7d5c85c9e0eff99f4c8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let _; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..d03a318ae0b99d782ad9be5c89d628b4911e4acb --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[Type]] is throw, return Completion(completion). + 7. If innerResult.[[Type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let _; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..9391d14623cb873efbf54e01afa6830132bc2cba --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when assignment evaluation has exhausted the + iterator +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let _; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ _ ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 0); + +//- teardown +iter.next().then(() => { + assert.sameValue(iterCount, 1); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case new file mode 100644 index 0000000000000000000000000000000000000000..55aa045efbf9f6700b30ad02e2b14d16dd5d3b76 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case @@ -0,0 +1,62 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is called when assignment evaluation has not exhausted the + iterator +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + [...] +features: [Symbol.iterator] +template: default +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let _; +let iterable = {}; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +iterable[Symbol.iterator] = function() { + return iterator; +}; +//- elems +[ _ ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 1); +assert.sameValue(thisValue, iterator, 'correct `this` value'); +assert(!!args, 'arguments object provided'); +assert.sameValue(args.length, 0, 'zero arguments specified'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..ff7953160a69bb844f2b49b7a8fc472f32637ce8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case @@ -0,0 +1,49 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[Type]] is throw, return Completion(completion). + 7. If innerResult.[[Type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let unreachable = 0; +let iterator = { + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ {}[yield] ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(unreachable, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..71d03881c431d0a6e275763b1a4c364e74378862 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case @@ -0,0 +1,46 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when iteration produces an abrupt completion +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterator = { + next() { + nextCount += 1; + throw new Test262Error(); + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +let _; + +//- elems +[ x ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 0); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..c61cdc9a8282856cc399793196fddea85af1d1ab --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +template: error-async-function-syntax +es6id: 12.14.5.1 +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[[(x, y)]] +//- vals +[[]] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case new file mode 100644 index 0000000000000000000000000000000000000000..7d2d69ddbd9ed3a0013227001101c5ddb5a4d774 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is + `null`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ _ ]] +//- vals +[null] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..cee7a05585d79e697ea22f8adebad5f4f1798d4d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is a + "hole", a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ _ ]] +//- vals +[ , ] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..0b19e67885f82c026114ae30925ae16ad743a0e6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is + `undefined`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ x ]] +//- vals +[undefined] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..cba070d9369650c64984d4abd820bdd6c9b9be64 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and no value is + defined, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; +//- elems +[[ x ]] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..1d322f0d253ef5c2c3be1313a5c2411e8b852cef --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment and within a generator function body, it + behaves as a YieldExpression. +template: async-generator +es6id: 12.14.5.3 +features: [generators] +---*/ + +//- setup +let value = [[22]]; +let x = {}; + +//- elems +[[x[yield]]] +//- vals +value +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x.prop, 22); + }, $DONE).then($DONE, $DONE); +}, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..bf7e26e6c3d725382075bd18019605979237665d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment outside of strict mode, it behaves as an + IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.3 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[[x[yield]]] +//- vals +[[]] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..6ec543b1656b6d53481e1c8c6c83826285fab9d3 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment outside of strict mode, it behaves as an + IdentifierReference. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +[[x[yield]]] +//- vals +[[22]] +//- body +assert.sameValue(x.prop, 22); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array.case b/src/dstr-assignment-async-iteration/array-elem-nested-array.case new file mode 100644 index 0000000000000000000000000000000000000000..7ccce4947f40a2b1ba442bfafd328cced36f502c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: async-function +---*/ + +//- setup +let x; +//- elems +[[x]] +//- vals +[[1]] +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..c4b38e413d43fe9cf49be174e44567686cc8b2b5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +template: error-async-function-syntax +es6id: 12.14.5.1 +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[{ get x() {} }] +//- vals +[{}] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case new file mode 100644 index 0000000000000000000000000000000000000000..24025d5cf64003171134fef6319acb907a7052d6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is + `null`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x; +//- elems +[{ x }] +//- vals +[null] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..9dd7c5eb495b0ddf0fc5ef9f0e9f71aca01135a8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is a + "hole", a TypeError should be thrown. +template: default +es6id: 12.14.5.3 + +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[ , ] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..7b2a81724226ad2f2052038cd0ff1f864a9f4693 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is + `undefined`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 + +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[undefined] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..19b426f710bb6068adeb1ff46723a479ebc3714d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and no value is + defined, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..8d1e3e58583cf86a019751198342eaea956d015c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it behaves + as a YieldExpression. +template: async-generator +---*/ + +//- setup +let x; + + +//- elems +[{ x = yield }] +//- vals +[{}] +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 4); + }, $DONE).then($DONE, $DONE); +}, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..6edca7faf60cc9c3234fda90548b729556a1aeed --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment outside of a generator function body, it behaves + as a IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.3 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[{ x = yield }] +//- vals +[{}] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..be16ef13ad28fc37d24a5c8370755b0da7cc2606 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment outside of a generator function body, it behaves + as an IdentifierReference. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 2; +let x; +//- elems +[{ x = yield }] +//- vals +[{}] +//- body +assert.sameValue(x, 2); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..41f922d2bdf5d9de38bd21cbdb355ffbbd13f0b5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +---*/ + +//- setup +let x; +//- elems +[{ x }] +//- vals +[{ x: 2 }] +//- body +assert.sameValue(x, 2); + + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-const.case b/src/dstr-assignment-async-iteration/array-elem-put-const.case new file mode 100644 index 0000000000000000000000000000000000000000..60709de651fc4ce18bc40bd8817f5194ac3e8707 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-const.case @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The assignment target should obey `const` semantics. +template: default +es6id: 12.14.5.3 +features: [const] +---*/ + +//- setup +const c = null; +//- elems +[ c ] +//- vals +[1] diff --git a/src/dstr-assignment-async-iteration/array-elem-put-let.case b/src/dstr-assignment-async-iteration/array-elem-put-let.case new file mode 100644 index 0000000000000000000000000000000000000000..69a58f42813d25991ecb8f7e0f12e658526bd065 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-let.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The assignment target should obey `let` semantics. +template: default +es6id: 12.14.5.3 +features: [let] +---*/ + +//- elems +[ x ] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); + +let x; diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case new file mode 100644 index 0000000000000000000000000000000000000000..67fde98843b539491554c886de343c944aa6fcfc --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the DestructuringAssignmentTarget of an AssignmentElement is a + PropertyReference, it should not be evaluated. +template: default +---*/ + +//- setup +let x, setValue; +x = { + get y() { + $ERROR('The property should not be accessed.'); + }, + set y(val) { + setValue = val; + } +}; +//- elems +[x.y] +//- vals +[23] +//- body +assert.sameValue(setValue, 23); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case new file mode 100644 index 0000000000000000000000000000000000000000..fdba045b9b2df28190446c2a270d2f619234a3d0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Any error raised as a result of setting the value should be forwarded to + the runtime. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = { + set y(val) { + throw new Test262Error(); + } +}; +//- elems +[x.y] +//- vals +[23] + +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case new file mode 100644 index 0000000000000000000000000000000000000000..9d18ee63c52d64a789833af9c276e667d398f547 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The DestructuringAssignmentTarget of an AssignmentElement may be a + PropertyReference. +template: default +---*/ + +//- setup +let x = {}; +//- elems +[x.y] +//- vals +[4] +//- body +assert.sameValue(x.y, 4); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..af3084436e265aa698c5307a502484b36364dbce --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +flags: [noStrict] +---*/ + +//- elems +[ unresolvable ] +//- vals +[] +//- body +assert.sameValue(unresolvable, undefined); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..33b0acc19e71dd72b32da6da2450a6dfa7335773 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + In strict mode, if the the assignment target is an unresolvable reference, + a ReferenceError should be thrown. +template: default +es6id: 12.14.5.3 +flags: [onlyStrict] +---*/ + +//- elems +[ unresolvable ] +//- vals +[] + +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-identifier.case b/src/dstr-assignment-async-iteration/array-elem-target-identifier.case new file mode 100644 index 0000000000000000000000000000000000000000..07d21bbb6e87be7040da5dd838aee6df2b0d66cf --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-identifier.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Identifiers that appear as the DestructuringAssignmentTarget in an + AssignmentElement should take on the iterated value corresponding to their + position in the ArrayAssignmentPattern. +template: async-function +---*/ + +//- setup +let x, y, z; +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case b/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..0f9f8ed3c537fb57f29ac0ca87dd4995f49c9b3b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Identifiers that appear as the DestructuringAssignmentTarget in an + AssignmentElement should take on the iterated value corresponding to their + position in the ArrayAssignmentPattern. +template: async-generator +flags: [noStrict] +---*/ + +//- setup +let argument, eval; +//- elems +[arguments, eval] +//- vals +[2, 3] +//- body +assert.sameValue(arguments, 2); +assert.sameValue(eval, 3); + + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case b/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..a68cc95cb2a95bedd546421042fdae4c608d9b2a --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is neither an + ObjectLiteral nor an ArrayLiteral and + IsValidSimpleAssignmentTarget(LeftHandSideExpression) is + false. +template: error-async-function-syntax +es6id: 12.14.5.1 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[arguments] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..0f796b4ea87b2aecebb875da5864bf9f8f8ec2a6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement within a generator function body, it behaves as a + YieldExpression. +template: async-generator +features: [generators] +---*/ + +//- setup +let value = [33]; +let x = {}; +let iterationResult; + +//- elems +[ x[yield] ] +//- vals +[33] + + +//- teardown +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x.prop, 33); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..d22bab44e17f1582049b244365f2a3fe5ab3c332 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and outside of a generator function body, it behaves as + an IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.4 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[ x[yield] ] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..47f18669655a6ba5fcbb9a5e87226a3b6790ac8a --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement outside of a generator function body, it behaves as an + IdentifierReference. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +[ x[yield] ] +//- vals +[33] +//- body +assert.sameValue(x.prop, 33); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case new file mode 100644 index 0000000000000000000000000000000000000000..29f053d1a5d36360637cb0f5ff8a1cafd99b4bfe --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case @@ -0,0 +1,63 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned during evaluation of elision +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + i. If iteratorRecord.[[done]] is false, return + IteratorClose(iterator, status). + ii. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + + if (nextCount === 2) { + throw new Test262Error(); + } + + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , , ] +//- vals +iterable +//- teardown + +iter.next().then(() => { + iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 2); + assert.sameValue(returnCount, 0); + assert.sameValue(constructor, Test262Error); + + }).then($DONE, $DONE); +}, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..96dd11cabe853106d9f2467e1bfc2254595a5ce1 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + [...] + 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(nextCount, 2); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + + + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..5b831a9de408bf6ad899a3cc5a4c4931b1855cc1 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + [...] + 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 6. Let innerResult be Call(return, iterator, « »). + 7. If completion.[[type]] is throw, return Completion(completion). + 8. If innerResult.[[type]] is throw, return Completion(innerResult). + 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. +features: [Symbol.iterator] +template: default +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let x; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- error +TypeError +//- elems +[ x , , ] +//- vals +iterable diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..835a6ad7da9f2e8b9f81bc9a331d52141a04501a --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case @@ -0,0 +1,57 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: IteratorClose not invoked when elision exhausts the iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 5. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + + [...] + + 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + 9. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + + return { done: nextCount > 1 }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ x , , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 2); +assert.sameValue(returnCount, 0); + + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case new file mode 100644 index 0000000000000000000000000000000000000000..0ae8bcccafe8e4281e637ae308739a81975e7d8c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case @@ -0,0 +1,72 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: IteratorClose invoked when elision does not exhaust the iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 5. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + + [...] + + 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let x; +let iterator = { + next() { + nextCount += 1; + + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 2); +assert.sameValue(returnCount, 1); +assert.sameValue(thisValue, iterator, 'correct `this` value'); +assert(!!args, 'arguments object provided'); +assert.sameValue(args.length, 0, 'zero arguments specified'); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case new file mode 100644 index 0000000000000000000000000000000000000000..5fcb2eacb5ea9268382aefc8689f23ac0a80351d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from GetIterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterable = { + [Symbol.iterator]() { + throw new Test262Error(); + } +}; +let x; +//- elems +[ x , ] +//- vals +iterable + +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..fe44dc0900e76d4de47b3b311648ff4331bd7db6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thrower = function() { + throw new Test262Error(); +}; +let x; +let iterator = { + next() { + nextCount += 1; + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..8669d0013c69e07c232dce081f1bbc6c71d44175 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case @@ -0,0 +1,65 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let x; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- error +TypeError +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..d1828dc29cace18444cd44d9018a7b064092e0d8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case @@ -0,0 +1,57 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not invoked when evaluation of AssignmentElementList + exhausts the iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + b. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thrower = function() { + throw new Test262Error(); +}; +let x; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ x , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 0); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case new file mode 100644 index 0000000000000000000000000000000000000000..04f371d5acbba66dddc87fc43c9778dac6f6e93e --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case @@ -0,0 +1,70 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is invoked when evaluation of AssignmentElementList completes + without exhausting the iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + b. Return Completion(status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let x; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ x , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 1); +assert.sameValue(thisValue, iterator, 'correct `this` value'); +assert(!!args, 'arguments object provided'); +assert.sameValue(args.length, 0, 'zero arguments specified'); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..284200130270f9ab60b4911ad758d8c6513e7ae2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is invoked when evaluation of AssignmentElementList returns + a "return" completion and the iterator has not been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let returnCount = 0; +let unreachable = 0; +let iterator = { + return() { + returnCount += 1; + + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(returnCount, 1); + assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..7b8971233e23bd52e8c51636281fa69ab9ed5e50 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterator = { + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + + +//- elems + [ {}[yield] , ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case new file mode 100644 index 0000000000000000000000000000000000000000..bb04127070d7171ffa4e1b4d5f97a9ac52becc2d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case @@ -0,0 +1,68 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is invoked when evaluation of AssignmentElementList returns + a "return" completion and the iterator has not been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let returnCount = 0; +let unreachable = 0; +let thisValue = null; +let args = null; +let iterator = { + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + + +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body + unreachable += 1; +//- teardown +iter.return(888).then(result => { + assert.sameValue(returnCount, 1); + assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); + assert.sameValue(result.value, 888); + assert(result.done, 'Iterator correctly closed'); + assert.sameValue(thisValue, iterator, 'correct `this` value'); + assert(!!args, 'arguments object provided'); + assert.sameValue(args.length, 0, 'zero arguments specified'); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..c01dd08a5aa0542932e5c498f1bce0b945bf4fef --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case @@ -0,0 +1,58 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not invoked when evaluation of AssignmentElementList + returns an abrupt completion and the iterator has been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. + 4. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 5. If status is an abrupt completion, then + a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + b. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterable = {}; +let thrower = function() { + throw new Test262Error(); +}; +let iterator = { + next() { + nextCount += 1; + throw new Test262Error(); + }, + return() { + returnCount += 1; + } +}; +iterable[Symbol.iterator] = function() { + return iterator; +}; +let x; +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 0); + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..892f618f8bab499279f98727ab195b03b9401f70 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when rest element evaluation has exhausted the + iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x, y; +let iterator = { + next() { + nextCount += 1; + return { value: nextCount, done: nextCount > 1 }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ x , ...y ] +//- vals +iterable +//- teardown +iter.next().then(() => { + iter.return().then(() => { + assert.sameValue(nextCount, 2, 'nextCount'); + assert.sameValue(returnCount, 0, 'returnCount'); + assert.sameValue(x, 1, 'x'); + assert.sameValue(y.length, 0, 'y.length'); + }).then($DONE, $DONE); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..c283de7cbfbd4b958e01c24d20e4d2025c296d96 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case @@ -0,0 +1,69 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is called when AssignmentRestEvaluation produces a "return" + completion due to reference evaluation +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let unreachable = 0; +let x; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- body + unreachable += 1; +//- teardown +iter.next().then(() => { + iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); + }).then($DONE, $DONE); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..69681bac100da0fbb930dba8fa5ea89100ae2d9c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..7edf63e32f873572b5957326e07a0cf91b137726 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case @@ -0,0 +1,49 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when iteration has exhausted the iterator +info: | + ArrayAssignmentPattern : [ Elision ] + + 1. Let iterator be ? GetIterator(value). + + [...] + + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).. + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 0); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case new file mode 100644 index 0000000000000000000000000000000000000000..b4093905f45731aa1c311be9afb79588e9792f10 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case @@ -0,0 +1,67 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is called when assignment evaluation has not exhausted the + iterator +info: | + ArrayAssignmentPattern : [ Elision ] + + 1. Let iterator be ? GetIterator(value). + + [...] + + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).. + [...] + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ , ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 1); +assert.sameValue(thisValue, iterator, 'correct `this` value'); +assert(!!args, 'arguments object provided'); +assert.sameValue(args.length, 0, 'zero arguments specified'); + + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elision-val-array.case b/src/dstr-assignment-async-iteration/array-elision-val-array.case new file mode 100644 index 0000000000000000000000000000000000000000..24817be114adb5c2d5d8c3b1901af7b5dd6da1e2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elision-val-array.case @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values +template: default +---*/ + +//- elems +[,] +//- vals +[] + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elision-val-string.case b/src/dstr-assignment-async-iteration/array-elision-val-string.case new file mode 100644 index 0000000000000000000000000000000000000000..c7dba9e14728eb2a32f8473618cc7e327d3ea696 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elision-val-string.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values +template: default +---*/ + +//- elems +[,] +//- vals +'string literal' + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-empty-iter-close.case b/src/dstr-assignment-async-iteration/array-empty-iter-close.case new file mode 100644 index 0000000000000000000000000000000000000000..36136e5813e2dbc1f611678dd007ca4ace89e456 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-empty-iter-close.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Iterator is closed without iterating +info: | + ArrayAssignmentPattern : [ ] + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + 3. Return IteratorClose(iterator, NormalCompletion(empty)). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[] +//- vals +iterable +//- body +assert.sameValue(nextCount, 0); +assert.sameValue(returnCount, 1); +assert.sameValue(thisValue, iterator, 'correct `this` value'); +assert(!!args, 'arguments object provided'); +assert.sameValue(args.length, 0, 'zero arguments specified'); + + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-empty-val-array.case b/src/dstr-assignment-async-iteration/array-empty-val-array.case new file mode 100644 index 0000000000000000000000000000000000000000..7f9aaf7643719f0145c150cc610afd3fcb53defa --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-empty-val-array.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values. +template: default +---*/ + +//- elems +[] +//- vals +[] + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-empty-val-string.case b/src/dstr-assignment-async-iteration/array-empty-val-string.case new file mode 100644 index 0000000000000000000000000000000000000000..6d6d18a3c39c263b1aae4a89f7137c7ff9fbf496 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-empty-val-string.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values. +template: default +---*/ + +//- elems +[] +//- vals +'string literal' + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-after-element.case b/src/dstr-assignment-async-iteration/array-rest-after-element.case new file mode 100644 index 0000000000000000000000000000000000000000..df52c96847ddbcea5882beb4f3496792c80a9940 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-after-element.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An AssignmentRestElement following an AssignmentElement consumes all + remaining iterable values. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x, y; +//- elems +[x, ...y] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y.length, 2); +assert.sameValue(y[0], 2); +assert.sameValue(y[1], 3); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-after-elision.case b/src/dstr-assignment-async-iteration/array-rest-after-elision.case new file mode 100644 index 0000000000000000000000000000000000000000..5dd350dd41e49e9fa34a9da13768993d8fe6ab40 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-after-elision.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An AssignmentRestElement following an elision consumes all remaining + iterable values. +template: default +---*/ + +//- setup +let x; +//- elems +[, ...x] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x.length, 2); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 3); + + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-elision.case b/src/dstr-assignment-async-iteration/array-rest-elision.case new file mode 100644 index 0000000000000000000000000000000000000000..17f9c868c8c5487ef51fb51df9d716d77e23642c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-elision.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + ArrayAssignmentPattern may include elisions at any position preceeding a + AssignmentRestElement in a AssignmentElementList. +template: default +---*/ + +//- setup +let x, y; +//- elems +[, , x, , ...y] +//- vals +[1, 2, 3, 4, 5, 6] +//- body +assert.sameValue(x, 3); +assert.sameValue(y.length, 2); +assert.sameValue(y[0], 5); +assert.sameValue(y[1], 6); + + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..297d7d4f78cb06252a376584d4dee8ea675cc671 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case @@ -0,0 +1,50 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when assignment evaluation has exhausted the + iterator +info: | + ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] + + [...] + 4. Let result be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 6. Return result. +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ ...x ] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 0); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-iteration.case b/src/dstr-assignment-async-iteration/array-rest-iteration.case new file mode 100644 index 0000000000000000000000000000000000000000..effa4f674440b09d4503a488600668622b7c1d50 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-iteration.case @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + In the presense of an AssignmentRestElement, value iteration exhausts the + iterable value; +template: default +es6id: 12.14.5.3 +features: [generators] +---*/ + +//- setup +let count = 0; +let g = function*() { + count += 1; + yield; + count += 1; + yield; + count += 1; +} +let x; +//- elems +[...x] +//- vals +g() +//- body +assert.sameValue(count, 3); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + + diff --git a/src/dstr-assignment-async-iteration/array-rest-lref.case b/src/dstr-assignment-async-iteration/array-rest-lref.case new file mode 100644 index 0000000000000000000000000000000000000000..e4e2cc80e88d945e743aeb17977974c96725c430 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-lref.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Reference is evaluated during assignment +info: | + ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] + + [...] + 4. Let result be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + + + AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget + + 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an + ArrayLiteral, then + a. Let lref be the result of evaluating DestructuringAssignmentTarget. + b. ReturnIfAbrupt(lref). + [...] +features: [Symbol.iterator] +template: async-generator +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterator = { + next() { + nextCount += 1; + return { done: true }; + }, + return() { + returnCount += 1; + } +}; +let obj = {}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[...obj['a' + 'b']] +//- vals +iterable +//- body +assert.sameValue(nextCount, 1); +assert.sameValue(returnCount, 0); +assert(!!obj.ab); +assert.sameValue(obj.ab.length, 0); + +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case new file mode 100644 index 0000000000000000000000000000000000000000..9949ba9abf0c63ccf7d526c9c281443d6ca5dd53 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable + emits `null` as the only value, an array with a single `null` element + should be used as the value of the nested DestructuringAssignment. +template: default +---*/ + +//- setup +let x, y; +//- elems +[...[x, y]] +//- vals +[null] +//- body +assert.sameValue(x, null); +assert.sameValue(y, undefined); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..850a1162ce93db8f33018795bfb6ade5576b256f --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable is + an array with a "hole", an array with a single `undefined` element should + be used as the value of the nested DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +//- elems +[...[x]] +//- vals +[ , ] +//- body +assert.sameValue(x, undefined); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..8cb676ff6ed7c4e41e96391881ddc27a2760e2b5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable + emits `undefined` as the only value, an array with a single `undefined` + element should be used as the value of the nested DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +//- elems +[...[x]] +//- vals +[undefined] +//- body +assert.sameValue(x, undefined); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..6069e8969758050ee05e07ac5ba51114f9fc3933 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable is + emits no values, an empty array should be used as the value of the nested + DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +//- elems +[...[x]] +//- vals +[] +//- body +assert.sameValue(x, undefined); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..d3e60ed236ba2f7daf698c5fac49b05281947630 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment and within a generator function body, it + should behave as a YieldExpression. +template: async-generator +features: [generators] +---*/ + +//- setup +let x = {}; + +//- elems +[...[x[yield]]] +//- vals +[86] +//- teardown +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x.prop, 86); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..d9edb6dc66e7744245ea9bd5297960ff751ff883 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment and outside of a generator function body, + it should behave as an IdentifierExpression. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +[...[x[yield]]] +//- vals +[86] +//- body +assert.sameValue(x.prop, 86); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array.case b/src/dstr-assignment-async-iteration/array-rest-nested-array.case new file mode 100644 index 0000000000000000000000000000000000000000..2d9ae7b62a3777bb7688d55394bffc86856dcb1b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x; +//- elems +[...[x]] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case new file mode 100644 index 0000000000000000000000000000000000000000..fa38c07d1805bd85d61fb52070ccc77e05856164 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the iterable + emits `null` as the only value, an array with a single `null` element + should be used as the value of the nested DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x, length; +//- elems +[...{ 0: x, length }] +//- vals +[null] +//- body +assert.sameValue(x, null); +assert.sameValue(length, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..1893815708e3c5f59056f414a91038af69dc1df0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable is + an array with a "hole", an array with a single `undefined` element should + be used as the value of the nested DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +// Use the the top-level lexical scope for 'length' to provide compatibility with browsers +// where length and name are properties of WindowProxy +let length; +//- elems +[...{ 0: x, length }] +//- vals +[ , ] +//- body +assert.sameValue(x, undefined); +assert.sameValue(length, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..fa864bc3d5f3c8e485990fe3206120a453253feb --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the iterable + emits `undefined` as the only value, an array with a single `undefined` + element should be used as the value of the nested DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +// Use the the top-level lexical scope for 'length' to provide compatibility with browsers +// where length and name are properties of WindowProxy +let length; +//- elems +[...{ 0: x, length }] +//- vals +[undefined] +//- body +assert.sameValue(x, undefined); +assert.sameValue(length, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..9723b02433394a589c6b38190dc45e12bf2b7c50 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an obect literal and the iterable is + emits no values, an empty array should be used as the value of the nested + DestructuringAssignment. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = null; +// Use the the top-level lexical scope for 'length' to provide compatibility with browsers +// where length and name are properties of WindowProxy +let length; +//- elems +[...{ 0: x, length }] +//- vals +[] +//- body +assert.sameValue(x, undefined); +assert.sameValue(length, 0); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..110ba07bf04784a9b5b5119ecc024471eb315e91 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it should + behave as a YieldExpression. +template: async-generator +features: [generators] +---*/ + +//- setup +let x; + +//- elems +[...{ x = yield }] +//- vals +[{}] +//- teardown +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x, 4); + }).then($DONE, $DONE); +}); + diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..12841d7d6a24129ff9098584baae05babb511562 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and outside of a generator function body, it + should behave as an IdentifierExpression. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 2; +let x; +//- elems +[...{ x = yield }] +//- vals +[{}] +//- body +assert.sameValue(x, 2); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..c248030593fb933c765ff6a5ee4622b9e0563c5b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +---*/ + +//- setup +let x; +//- elems +[...{ 1: x }] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case new file mode 100644 index 0000000000000000000000000000000000000000..0a2daa2d56f943040f26ff04c7d8d436c197695b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the DestructuringAssignmentTarget of an AssignmentElement is a + PropertyReference, it should not be evaluated. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let setValue; +let x = { + get y() { + $ERROR('The property should not be accessed.'); + }, + set y(val) { + setValue = val; + } +}; +//- elems +[...x.y] +//- vals +[23, 45, 99] +//- body +assert.sameValue(setValue.length, 3); +assert.sameValue(setValue[0], 23); +assert.sameValue(setValue[1], 45); +assert.sameValue(setValue[2], 99); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case new file mode 100644 index 0000000000000000000000000000000000000000..4af124f33665a61aac0bf84b462173b0779ef014 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The DestructuringAssignmentTarget of an AssignmentElement may be a + PropertyReference. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = {}; +//- elems +[...x.y] +//- vals +[4, 3, 2] +//- body +assert.sameValue(x.y.length, 3); +assert.sameValue(x.y[0], 4); +assert.sameValue(x.y[1], 3); +assert.sameValue(x.y[2], 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..f7221ff117aae812c5bdbe3d8b6beda0c51b71b9 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +flags: [noStrict] +---*/ + +//- elems +[ ...unresolvable ] +//- vals +[] +//- body +assert.sameValue(unresolvable.length, 0); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..acc1dcb7901544ddf9358ecaa82a337f4f92ab25 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-yield-expr.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of + an AssignmentRestElement and within the body of a generator function, it + should behave as a YieldExpression. +template: async-generator +features: [generators] +---*/ + +//- setup +let x = {}; + +//- elems +[...x[yield]] +//- vals +[33, 44, 55] +//- teardown +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x.prop.length, 3); + assert.sameValue(x.prop[0], 33); + assert.sameValue(x.prop[1], 44); + assert.sameValue(x.prop[2], 55); + assert.sameValue(iterCount, 1); + }).then($DONE, $DONE); +}); + diff --git a/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..9d3319a38ca16621a8a94f2ab88b982d762aa715 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentRestElement and outside of a generator function body, it should + behave as an IdentifierReference. +template: async-function +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +[...x[yield]] +//- vals +[33, 44, 55] +//- body +assert.sameValue(x.prop.length, 3); +assert.sameValue(x.prop[0], 33); +assert.sameValue(x.prop[1], 44); +assert.sameValue(x.prop[2], 55); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/async-function/async-func-decl.template b/src/dstr-assignment-async-iteration/async-function/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..31f598a0600ebae2852b763839db760830db1d64 --- /dev/null +++ b/src/dstr-assignment-async-iteration/async-function/async-func-decl.template @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +let iterCount = 0; +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + iterCount += 1; + } +} + +let promise = fn(); diff --git a/src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template b/src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..1fc6dbcd62b073d35cea6028ee764223867190ed --- /dev/null +++ b/src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-decl-dstr- +name: for-await-of statement in an async generator declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +let iterCount = 0; +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + iterCount += 1; + } +} + +let iter = fn(); diff --git a/src/dstr-assignment-async-iteration/default/async-func-decl.template b/src/dstr-assignment-async-iteration/default/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..31f598a0600ebae2852b763839db760830db1d64 --- /dev/null +++ b/src/dstr-assignment-async-iteration/default/async-func-decl.template @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +let iterCount = 0; +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + iterCount += 1; + } +} + +let promise = fn(); diff --git a/src/dstr-assignment-async-iteration/default/async-gen-decl.template b/src/dstr-assignment-async-iteration/default/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..70c488d468778741dc7fe4e6ddeaa7f6b167a4b0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/default/async-gen-decl.template @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-decl-dstr- +name: for-await-of statement in an async generator declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +let iterCount = 0; +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + iterCount += 1; + } +} + +let promise = fn().next(); diff --git a/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template b/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..a6d537c9eedc0743e1a4f410ad7720e5f92790ea --- /dev/null +++ b/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) +} diff --git a/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template b/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..90fe373fb19491fd02b6c154bb5a57ff5c2aa717 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) +} diff --git a/src/dstr-assignment-async-iteration/error/async-func-decl.template b/src/dstr-assignment-async-iteration/error/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..0fd7dffec0e0b5f971f8330120381fb14b32dfc8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error/async-func-decl.template @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + } +} + +let promise = fn(); diff --git a/src/dstr-assignment-async-iteration/error/async-gen-decl.template b/src/dstr-assignment-async-iteration/error/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..47425432f5de26a289ac3346d36e5ef23e75e3f6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error/async-gen-decl.template @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-decl-dstr- +name: for-await-of statement in an async generator declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + } +} + +let promise = fn().next(); + diff --git a/src/dstr-assignment-async-iteration/obj-empty-bool.case b/src/dstr-assignment-async-iteration/obj-empty-bool.case new file mode 100644 index 0000000000000000000000000000000000000000..b7515ae5888cd2ea8b1f8e08916ca824f54fe701 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-bool.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (boolean value) +template: default +---*/ + +//- elems +{} +//- vals +false +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-num.case b/src/dstr-assignment-async-iteration/obj-empty-num.case new file mode 100644 index 0000000000000000000000000000000000000000..de42463600f03bd28a3351f11f9150db472f70d2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-num.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (number value) +template: default +---*/ + +//- elems +{} +//- vals +0 + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-obj.case b/src/dstr-assignment-async-iteration/obj-empty-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..aa4e88ed14e5a90a9bd823bed872b51bbf3ea367 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-obj.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (object value) +template: default +---*/ + +//- elems +{} +//- vals +{} +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-string.case b/src/dstr-assignment-async-iteration/obj-empty-string.case new file mode 100644 index 0000000000000000000000000000000000000000..2531e7af9377c32240c4ea2a12cc5547ed0a061b --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-string.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (string value) +template: default +---*/ + +//- elems +{} +//- vals +'' +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-symbol.case b/src/dstr-assignment-async-iteration/obj-empty-symbol.case new file mode 100644 index 0000000000000000000000000000000000000000..6dff904138782b2c36607717a6e9aef122bf6345 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-symbol.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (symbol value) +template: default +features: [Symbol] +---*/ + +//- setup +let s = Symbol(); +//- elems +{} +//- vals +s +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..2e7f0ffbea0f22be3dddb481a383e45c3a341eb6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (first of many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let y; +//- elems +{ x, y } +//- vals +{ x: 3 } +//- body +assert.sameValue(x, 3); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..891a39bf9a4245382a2295e405201820bc41e662 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (last of many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w; +//- elems +{ w, x } +//- vals +{ x: 4 } +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..e587e08cba462be3b22df3e936ffe8a380729457 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone identifier) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ x, } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..e18d9874553bdb535624f286b2889aa745486cc2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (within many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w, y; +//- elems +{ w, x, y } +//- vals +{ x: 5 } +//- body +assert.sameValue(x, 5); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..baff69ebd8832a8f3b6ec814cca0c6341d3b855e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone identifier with trailing + comma) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ x } +//- vals +{ x: 1 } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..35af6aaad6b63f624cf9d0aedc3f1da1ee476c09 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (no corresponding + property defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..363aa9efc2d107727d5829475dbcc4bf99e7eb24 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (null property + value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: null } +//- body +assert.sameValue(x, null); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..135149127ae734f7e8751155372ff6bb3bcd8604 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (truthy property + value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..2eaea90f40c71b3bcfdeb14e9d28563a54b71c0d --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference ("undefined" + property value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: undefined } +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case b/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..be1928c8b759fc5d8fd80efded07ae3a2eae89af --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer should only be evaluated if v is undefined. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let flag1 = false; +let flag2 = false; +let x, y; +//- elems +{ x = flag1 = true, y = flag2 = true } +//- vals +{ y: 1 } +//- body +assert.sameValue(flag1, true); +assert.sameValue(flag2, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case new file mode 100644 index 0000000000000000000000000000000000000000..ffac568e75332a1f21f6fd6e16ab4d983bb6439f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ArrowFunction) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let arrow; +//- elems +{ arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); +verifyNotEnumerable(arrow, 'name'); +verifyNotWritable(arrow, 'name'); +verifyConfigurable(arrow, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case new file mode 100644 index 0000000000000000000000000000000000000000..36e269e8675eb6bb7d8685282eb988d8479eabab --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ClassExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xCls, cls, xCls2; +//- elems +{ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); + +assert.sameValue(cls.name, 'cls'); +verifyNotEnumerable(cls, 'name'); +verifyNotWritable(cls, 'name'); +verifyConfigurable(cls, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case new file mode 100644 index 0000000000000000000000000000000000000000..3f398fa41577a18c5578c6dc47356aecd0b2af72 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let xCover, cover; +//- elems +{ xCover = (0, function() {}), cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); + +assert.sameValue(cover.name, 'cover'); +verifyNotEnumerable(cover, 'name'); +verifyNotWritable(cover, 'name'); +verifyConfigurable(cover, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case new file mode 100644 index 0000000000000000000000000000000000000000..7c931ef72c9015f32b35d7f7669ed829134888ce --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (FunctionExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let xFnexp, fnexp; +//- elems +{ xFnexp = function x() {}, fnexp = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFnexp.name, 'xFnexp'); + +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case new file mode 100644 index 0000000000000000000000000000000000000000..da5c52c5b705eedee5ea74d5282bfc6cb169fb75 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +features: [generators] +---*/ + +//- setup +let xGen, gen; +//- elems +{ xGen = function* x() {}, gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); + +assert.sameValue(gen.name, 'gen'); +verifyNotEnumerable(gen, 'name'); +verifyNotWritable(gen, 'name'); +verifyConfigurable(gen, 'name'); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-in.case b/src/dstr-assignment-async-iteration/obj-id-init-in.case new file mode 100644 index 0000000000000000000000000000000000000000..548ede4bec6b3adda33a8656f4c7a91390a585c9 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-in.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer in an AssignmentProperty may be an `in` expression. +template: default +es6id: 12.14.5 +---*/ + +//- setup +let prop; +//- elems +{ prop = 'x' in {} } +//- vals +{} +//- body +assert.sameValue(prop, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-order.case b/src/dstr-assignment-async-iteration/obj-id-init-order.case new file mode 100644 index 0000000000000000000000000000000000000000..a5c60545b2e1bb0afef4c973c0e9c45ee3e1b5d4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-order.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Initializer values should be assigned in left-to-right order. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = 0; +let a, b; +//- elems +{ a = x += 1, b = x *= 2 } +//- vals +{} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..badf346f9282bf12dc7cb92774fb27096df18ef2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let eval, arguments; +//- elems +{ eval = 3, arguments = 4 } +//- vals +{} +//- body +assert.sameValue(eval, 3); +assert.sameValue(arguments, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case b/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..dbd2aaaed0940beef1a835be492ac4996604128a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentProperty and within a generator function body, it should behave + as a YieldExpression. +template: async-generator +es6id: 12.14.5 +features: [generators] +---*/ + +//- setup +let x; + +//- elems +{ x = yield } +//- vals +{} +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(3).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 3); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..c7d2db9c9dc8d91f03c79afe0d6dd58e402640df --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentProperty and outside of a generator function body, it should + behave as an IdentifierReference. +template: async-function +es6id: 12.14.5 +flags: [noStrict] +---*/ + +//- setup +let yield = 3; +let x; +//- elems +{ x = yield } +//- vals +{} +//- body +assert.sameValue(x, 3); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..ea28e25faad39205b90c2e2b7aca6e081f223d79 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +{ +//- elems +{ unresolvable } +//- vals +{} +//- teardown +promise + .then(() => { + assert.sameValue(unresolvable, undefined); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); +} diff --git a/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..bbff2331c6db067108c4fff60d792c77ea8aa11c --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let eval; +//- elems +{ eval } +//- vals +{ eval: 1 } +//- teardown +promise + .then(() => { + assert.sameValue(eval, 1); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..444385fd34df13db07897fe141ad40fa6bc64016 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (non-existent + property) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..0c41d3a32cc3a4cff87e6ff8f8e5bb0fc096aad7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is not undefined, the Initializer should + be evaluated and the result assigned to the target reference (null value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: null } +//- body +assert.sameValue(x, null); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..575026770b50a47a6fac48b08e55fa8468116895 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is not undefined, the Initializer should + be evaluated and the result assigned to the target reference (truthy value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..947dbcd2a3a99c81c6d707b29a32fe7722842c9f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (undefined value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: undefined } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..cdca15202c65b6d3f81fbcf216f5ed59ac212c94 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer should only be evaluated if v is undefined. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let flag1 = false; +let flag2 = false; +let x, y; +//- elems +{ x: x = flag1 = true, y: y = flag2 = true } +//- vals +{ y: 1 } +//- body +assert.sameValue(x, true, 'value of `x`'); +assert.sameValue(flag1, true, 'value of `flag1`'); +assert.sameValue(y, 1, 'value of `y`'); +assert.sameValue(flag2, false, 'value of `flag2`'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case new file mode 100644 index 0000000000000000000000000000000000000000..1fe46df9477e87e35166ef9904870ddf620b3899 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ArrowFunction) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let arrow; +//- elems +{ x: arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); +verifyNotEnumerable(arrow, 'name'); +verifyNotWritable(arrow, 'name'); +verifyConfigurable(arrow, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case new file mode 100644 index 0000000000000000000000000000000000000000..a5ba2e3a050976d3a63f29267f85035a01d8bc05 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ClassExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xCls, cls, xCls2; +//- elems +{ x: xCls = class x {}, x: cls = class {}, x: xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); + +assert.sameValue(cls.name, 'cls'); +verifyNotEnumerable(cls, 'name'); +verifyNotWritable(cls, 'name'); +verifyConfigurable(cls, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case new file mode 100644 index 0000000000000000000000000000000000000000..dc28778daed69d5560036867b87b8e5fef4fdda6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let xCover, cover; +//- elems +{ x: xCover = (0, function() {}), x: cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); + +assert.sameValue(cover.name, 'cover'); +verifyNotEnumerable(cover, 'name'); +verifyNotWritable(cover, 'name'); +verifyConfigurable(cover, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case new file mode 100644 index 0000000000000000000000000000000000000000..bb4478d34c1f5f4a469974f3e334a641e85726d5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (FunctionExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let xFnexp, fnexp; +//- elems +{ x: xFnexp = function x() {}, x: fnexp = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFnexp.name, 'xFnexp'); + +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case new file mode 100644 index 0000000000000000000000000000000000000000..b9f7fc89c71fb67bdfd8ca57296b6e59bcbd6f71 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [generators] +---*/ + +//- setup +let xGen, gen; +//- elems +{ x: xGen = function* x() {}, x: gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); + +assert.sameValue(gen.name, 'gen'); +verifyNotEnumerable(gen, 'name'); +verifyNotWritable(gen, 'name'); +verifyConfigurable(gen, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case new file mode 100644 index 0000000000000000000000000000000000000000..ebde862cbed384d264b611f6b5cc37f6dabfc357 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer in an AssignmentElement may be an `in` expression. +template: default +es6id: 12.14.5 +---*/ + +//- setup +let prop; +//- elems +{ x: prop = 'x' in {} } +//- vals +{} +//- body +assert.sameValue(prop, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..0d01eb80fed70660f66fb2e0e348800050505feb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + and within a generator function body, it should behave as a + YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x; +//- elems +{ x: x = yield } +//- vals +{} +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(86).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 86); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..b06c24651f447b32a1b74fcf896f120516dd8ad3 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + and outside of a generator function body, it should behave as an + IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 4; +let x; +//- elems +{ x: x = yield } +//- vals +{} +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..10f4b54792cde8a8b9433dd9243a847b7a780164 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and within a generator function body, it should behave as + a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x = {}; +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x.prop, 23); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..04f9038968c1965b1bdf796f665426bce3d17be9 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and outside of a generator function body, it should + behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- body +assert.sameValue(x.prop, 23); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..226bdc79fa56c48d6afe84dad65db3fa2d8993f0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (first of many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let y; +//- elems +{ a: x, y } +//- vals +{ a: 3 } +//- body +assert.sameValue(x, 3); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..3efb3d355160de194e6c2b1d9952d7ccc1893ea7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (last of many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w; +//- elems +{ w, a: x } +//- vals +{ a: 4 } +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..fec596e5a98ab348d06f8b0bb0dc1e33c1c20d8c --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone element). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ a: x } +//- vals +{ a: 1 } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..f78417284063e751c416bff02dc9545ce35c54fb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (within many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w, y; +//- elems +{ w, a: x, y } +//- vals +{ a: 5 } +//- body +assert.sameValue(x, 5); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..c38a146cef089cff2df328d3a227a7939aa07f3a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone element with trailing + comma). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ a: x, } +//- vals +{ a: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case b/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..e40d850af342b0866077b63bcf0cec0003896707 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + PropertyName of an AssignmentProperty may be a ComputedPropertyName. +template: default +es6id: 12.14.5.2 +---*/ + +//- setup +let x, y, xy; +//- elems +{ ['x' + 'y']: x } +//- vals +{ x: 1, xy: 23, y: 2 } +//- body +assert.sameValue(x, 23); +assert.sameValue(y, undefined); +assert.sameValue(xy, undefined); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..32748683bb3f31e7d00b0c643b160ec0fca26a30 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it should + behave as a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x; + +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(24601).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 24601); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..5ebe36dddae934cdf6be48dc0fa190d10a2791ef --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and outside of a generator function body, it + should behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 22; +let x; +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- body +assert.sameValue(x, 22); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array.case new file mode 100644 index 0000000000000000000000000000000000000000..daa41735ef11c632d0762eb87cdf85d8c92626a2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let y; +//- elems +{ x: [y] } +//- vals +{ x: [321] } +//- body +assert.sameValue(y, 321); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..4124cd5a3d0821d6c021e1ae69b153777e522df4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it should + behave as a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x = undefined; + +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 4); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..5d6f65813d96690ad59823a036da3ee337155079 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and outside of a generator function body, it + should behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 2; +let result, x; +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..12ee4ff1eb3f937c734c8ce2c9ea96aad2218025 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let result, y; +//- elems +{ x: { y } } +//- vals +{ x: { y: 2 } } +//- body +assert.sameValue(y, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-order.case b/src/dstr-assignment-async-iteration/obj-prop-put-order.case new file mode 100644 index 0000000000000000000000000000000000000000..ad84d95b1edd26ce4d2039bc3a3631d7465f9360 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-order.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The AssignmentElements in an AssignmentElementList are evaluated in left- + to-right order. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ z: x, a: x } +//- vals +{ a: 2, z: 1 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case new file mode 100644 index 0000000000000000000000000000000000000000..3e1bbaffb6d75ac76476e29a67108797345f78d2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the DestructuringAssignmentTarget of an AssignmentElement is a + PropertyReference, it should not be evaluated. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let setValue; +let x = { + get y() { + $ERROR('The property should not be accessed.'); + }, + set y(val) { + setValue = val; + } +}; +//- elems +{ a: x.y } +//- vals +{ a: 23 } +//- body +assert.sameValue(setValue, 23); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case new file mode 100644 index 0000000000000000000000000000000000000000..1e2f676de1c4841ed7ebb548cb92440bd71f75b4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The DestructuringAssignmentTarget of an AssignmentElement may be a + PropertyReference. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = {}; +//- elems +{ xy: x.y } +//- vals +{ xy: 4 } +//- body +assert.sameValue(x.y, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..cdcebfb97c0900b8542d030c2e5849b132e0b31a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +{ +//- elems +{ x: unresolvable } +//- vals +{} +//- teardown +promise + .then(() => { + assert.sameValue(unresolvable, undefined); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); +} diff --git a/src/dstr-assignment-async-iteration/obj-rest-descriptors.case b/src/dstr-assignment-async-iteration/obj-rest-descriptors.case new file mode 100644 index 0000000000000000000000000000000000000000..b61100602536e9d9b274ac7dd98983813f210ec8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-descriptors.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Object created from rest deconstruction doesn't copy source + object property descriptors. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest; +let obj = {}; +Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true }); +Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true }); +//- elems +{...rest} +//- vals +obj +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case b/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..9cc4fe330268327acf1510834099ffe1aa04c51f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object even if lhs is an empty object +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +{} +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert.sameValue(typeof rest, "object"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-getter.case b/src/dstr-assignment-async-iteration/obj-rest-getter.case new file mode 100644 index 0000000000000000000000000000000000000000..6a3b38a2279634f53186713a792ce23c046f5373 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-getter.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Getter is called when obj is being deconstructed to a rest Object +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let x; +let count = 0; +//- elems +{...x} +//- vals +{ get v() { count++; return 2; } } +//- body +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case b/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case new file mode 100644 index 0000000000000000000000000000000000000000..716958f7e4feb40122c31cbd4a0fee18e6e6c460 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment and object rest desconstruction is allowed in that case. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let a, b, c, rest; +//- elems +{a, b, ...{c, ...rest}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case b/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..e2b18b84b85b930ac222589ba02222e9cf23cc06 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let a, b, c, d, e; +//- elems +{a, b, ...{c, e}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); +assert.sameValue(d, undefined); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-number.case b/src/dstr-assignment-async-iteration/obj-rest-number.case new file mode 100644 index 0000000000000000000000000000000000000000..44bfa8e7ba86aeb1d427c25694452d2be9e44acd --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-number.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object even if lhs is a Number +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +51 +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case b/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case new file mode 100644 index 0000000000000000000000000000000000000000..e804894b202b5673c0995d2fbaedaa64a8e8e6ea --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just source object's own properties +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +let x, y, z; +//- elems +{ x, ...{y , z} } +//- vals +o +//- body +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-same-name.case b/src/dstr-assignment-async-iteration/obj-rest-same-name.case new file mode 100644 index 0000000000000000000000000000000000000000..4906ffbb3b8ff29c2ed79e2ff25a2b0197b9f41e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-same-name.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Proper setting in the values for rest name equal to a property name. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let o = { + x: 42, + y: 39, + z: 'cheeseburger' +}; + +let x, y, z; +//- elems +{ x, ...z } +//- vals +o +//- body +assert.sameValue(x, 42); +assert.sameValue(y, undefined); +assert.sameValue(z.y, 39); +assert.sameValue(z.z, 'cheeseburger'); + +let keys = Object.keys(z); +assert.sameValue(keys.length, 2); +assert.sameValue(keys[0], 'y'); +assert.sameValue(keys[1], 'z'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case b/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case new file mode 100644 index 0000000000000000000000000000000000000000..a38daa7a96f14b824612b0fb344f09a5d6fc5d23 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object doesn't contain non-enumerable properties +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest; +let obj = {a: 3, b: 4}; +Object.defineProperty(obj, "x", { value: 4, enumerable: false }); +//- elems +{...rest} +//- vals +obj +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-str-val.case b/src/dstr-assignment-async-iteration/obj-rest-str-val.case new file mode 100644 index 0000000000000000000000000000000000000000..ef575bf556dbd2efc98709b4b21490b1a6a4b704 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-str-val.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creats an object with indexes as property name +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +"foo" +//- body +assert.sameValue(rest["0"], "f"); +assert.sameValue(rest["1"], "o"); +assert.sameValue(rest["2"], "o"); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case b/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case new file mode 100644 index 0000000000000000000000000000000000000000..4feed1a46499c0496da204e81c42c2bed0c7671e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object if lhs is a Symbol +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +Symbol("foo") +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case b/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case new file mode 100644 index 0000000000000000000000000000000000000000..d5db125a097e71c53f93e50b7ca707916948cfec --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object property setter, its value should be + binded as rest object. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let settedValue; +let executedGetter = false; +let src = { + get y() { + executedGetter = true; + }, + set y(v) { + settedValue = v; + }, +}; +src.y = undefined; +//- elems +{...src.y} +//- vals +{ x: 1, y: 2} +//- body +assert.sameValue(settedValue.x, 1); +assert.sameValue(settedValue.y, 2); +assert(!executedGetter, "The property should not be accessed"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-to-property.case b/src/dstr-assignment-async-iteration/obj-rest-to-property.case new file mode 100644 index 0000000000000000000000000000000000000000..fff09d20e8f00732fbc0eb59025878910b3ee1c8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-to-property.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object property, its value should be binded + as rest object. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let src = {}; +//- elems +{...src.y} +//- vals +{ x: 1, y: 2} +//- body +assert.sameValue(src.y.x, 1); +assert.sameValue(src.y.y, 2); + +verifyEnumerable(src, "y"); +verifyWritable(src, "y"); +verifyConfigurable(src, "y"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-valid-object.case b/src/dstr-assignment-async-iteration/obj-rest-valid-object.case new file mode 100644 index 0000000000000000000000000000000000000000..f959b8bbdc496c3222e494408470ad19dc60fccb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-valid-object.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just unextracted data +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest, a, b; + +//- elems +{a, b, ...rest} +//- vals +{x: 1, y: 2, a: 5, b: 3} +//- body +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment/default/for-await-of.template b/src/dstr-assignment/default/for-await-of.template new file mode 100644 index 0000000000000000000000000000000000000000..541520c4a158d5d92ec714e6ad8335b29285e6a4 --- /dev/null +++ b/src/dstr-assignment/default/for-await-of.template @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/dstr- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +var counter = 0; + +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + counter += 1; + } +} + +fn() + .then(() => assert.sameValue(counter, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-assignment-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-assignment-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..b293809c0dbca9b697da6429af3b4b8a886a48bb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-assignment-fn.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-assignment-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var v2, vNull, vHole, vUndefined, vOob; + +var iterCount = 0; +async function fn() { + for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) { + assert.sameValue(v2, 2); + assert.sameValue(vNull, null); + assert.sameValue(vHole, 12); + assert.sameValue(vUndefined, 13); + assert.sameValue(vOob, 14); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-evaluation-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-evaluation-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..d3f1e2c31548cfbc4445e8a2b99e7558d2e9caee --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-evaluation-fn.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-evaluation-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: The Initializer should only be evaluated if v is undefined. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var flag1 = false, flag2 = false; +var _; + +var iterCount = 0; +async function fn() { + for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) { + assert.sameValue(flag1, false); + assert.sameValue(flag2, true); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-arrow-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-arrow-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..7428724d0f0e560bb2fb4a8f08ac094514f7aab8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-arrow-fn.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var arrow; + +var iterCount = 0; +async function fn() { + for await ([ arrow = () => {} ] of [[]]) { + assert.sameValue(arrow.name, 'arrow'); + verifyNotEnumerable(arrow, 'name'); + verifyNotWritable(arrow, 'name'); + verifyConfigurable(arrow, 'name'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-class-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-class-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..88fb18c4855897c77bf1083b5afec2dc33457585 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-class-fn.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-class-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [class, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xCls, cls, xCls2; + +var iterCount = 0; +async function fn() { + for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) { + assert(xCls.name !== 'xCls'); + assert(xCls2.name !== 'xCls2'); + + assert.sameValue(cls.name, 'cls'); + verifyNotEnumerable(cls, 'name'); + verifyNotWritable(cls, 'name'); + verifyConfigurable(cls, 'name'); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..f555a07115f19940c4ac02895faa9ec30c4b5532 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-fn.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xCover, cover; + +var iterCount = 0; +async function fn() { + for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) { + assert(xCover.name !== 'xCover'); + + assert.sameValue(cover.name, 'cover'); + verifyNotEnumerable(cover, 'name'); + verifyNotWritable(cover, 'name'); + verifyConfigurable(cover, 'name'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-gen.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..3c9111e4a41f3f1470607d4cf2ee44c715047d56 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-cover-gen.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover-gen.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xCover, cover; + +var iterCount = 0; +async function fn() { + for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) { + assert(xCover.name !== 'xCover'); + + assert.sameValue(cover.name, 'cover'); + verifyNotEnumerable(cover, 'name'); + verifyNotWritable(cover, 'name'); + verifyConfigurable(cover, 'name'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..e8a71bb44bc2c5dd13290b9be819d60a80cbaa72 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-fn-name-fn.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [class, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xFn, fn; + +var iterCount = 0; +async function fn() { + for await ([ xFn = function x() {}, fn = function() {} ] of [[]]) { + assert(xFn.name !== 'xFn'); + + assert.sameValue(fn.name, 'fn'); + verifyNotEnumerable(fn, 'name'); + verifyNotWritable(fn, 'name'); + verifyConfigurable(fn, 'name'); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-in.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-in.js new file mode 100644 index 0000000000000000000000000000000000000000..7067339fccd52a9d86f014981f5bd6518dbadd15 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-in.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-in.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; + +var iterCount = 0; +async function fn() { + for await ([ x = 'x' in {} ] of [[]]) { + assert.sameValue(x, false); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-order.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-order.js new file mode 100644 index 0000000000000000000000000000000000000000..01cbd0f9d70cc6d7992e1142bf45b434ba0d240b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-order.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-order.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Initializer values should be assigned in left-to-right order. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x = 0; +var a, b; + +var iterCount = 0; +async function fn() { + for await ([ a = x += 1, b = x *= 2 ] of [[]]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(x, 2); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-init-simple-no-strict.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-simple-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..80488ea30c14ecff60f32d19e0c6f83a8d86ddfd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-init-simple-no-strict.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var argument, eval; + +var iterCount = 0; +async function fn() { + for await ([arguments = 4, eval = 5] of [[]]) { + assert.sameValue(arguments, 4); + assert.sameValue(eval, 5); + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array-yield-ident-valid.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array-yield-ident-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..129ee714bc56432ff2934af8e4226a9f19ea1d28 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array-yield-ident-valid.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var yield = 'prop'; +var x = {}; + +var iterCount = 0; +async function fn() { + for await ([[x[yield]]] of [[[22]]]) { + assert.sameValue(x.prop, 22); + iterCount += 1; + } +} diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array.js new file mode 100644 index 0000000000000000000000000000000000000000..593906b97f4e0d1d598fb4de5605841e9524a2ee --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-array.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-array.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; + +var iterCount = 0; +async function fn() { + for await ([[x]] of [[[1]]]) { + assert.sameValue(x, 1); + iterCount += 1; + } +} diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..35726a5819ffdce6ff74cea9099ecdf76cd8ab0b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-fn.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-obj-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; + +var iterCount = 0; +async function fn() { + for await ([{ x }] of [[{ x: 2 }]]) { + assert.sameValue(x, 2); + + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-yield-ident-valid-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-yield-ident-valid-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..8d48973842019e61fd34c5b8e1728b8cd6222152 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-nested-obj-yield-ident-valid-fn.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var yield = 2; +var x; + +var iterCount = 0; +async function fn() { + for await ([{ x = yield }] of [[{}]]) { + assert.sameValue(x, 2); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..52e30d420957b909af69dea12497077f21928f40 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-fn.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-put-prop-ref-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x = {}; + +var iterCount = 0; +async function fn() { + for await ([x.y] of [[4]]) { + assert.sameValue(x.y, 4); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-no-get-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-no-get-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..bf751d8fb9645e2b14a8885635446bf4ee885c51 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-prop-ref-no-get-fn.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x, setValue; +x = { + get y() { + $ERROR('The property should not be accessed.'); + }, + set y(val) { + setValue = val; + } +}; + +var iterCount = 0; +async function fn() { + for await ([x.y] of [[23]]) { + assert.sameValue(setValue, 23); + + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-array-elem-put-unresolvable-no-strict-fn.js b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-unresolvable-no-strict-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..68f8f991698755cd5af0dd38360c2c61d528c796 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-array-elem-put-unresolvable-no-strict-fn.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict-fn.case +// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template +/*--- +description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +var iterCount = 0; +async function fn() { + for await ([ unresolvable ] of [[]]) { + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js b/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..3d8861b8a1d8ec526c68a7d6d0daf39b2d110df9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case +// - src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template +/*--- +description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async generator declaration) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var argument, eval; + +let iterCount = 0; +async function * fn() { + for await ([arguments, eval] of [[2, 3]]) { + assert.sameValue(arguments, 2); + assert.sameValue(eval, 3); + + + iterCount += 1; + } +} + +let iter = fn(); + +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js b/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..19c4eb80033d40c9b47719004db20214de6b4429 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case +// - src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template +/*--- +description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var value = [33]; +var x = {}; +var iterationResult; + + +let iterCount = 0; +async function * fn() { + for await ([ x[yield] ] of [[33] + +]) { + + iterCount += 1; + } +} + +let iter = fn(); + +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x.prop, undefined); + + // TODO add iterCount + // + iter.next('prop').then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x.prop, 33); + }).then($DONE, $DONE); +}); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-assignment-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-assignment-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..0436b47c41726c553957eb0df87cad288924c909 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-assignment-gen.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-assignment-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var v2, vNull, vHole, vUndefined, vOob; + +var iterCount = 0; +async function * fn() { + for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) { + assert.sameValue(v2, 2); + assert.sameValue(vNull, null); + assert.sameValue(vHole, 12); + assert.sameValue(vUndefined, 13); + assert.sameValue(vOob, 14); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-evaluation-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-evaluation-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..940dbecd196fdc9b62ea3fb138e716f11e2b204f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-evaluation-gen.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-evaluation-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: The Initializer should only be evaluated if v is undefined. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var flag1 = false, flag2 = false; +var _; + +var iterCount = 0; +async function * fn() { + for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) { + assert.sameValue(flag1, false); + assert.sameValue(flag2, true); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-arrow-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-arrow-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..7418316daaa0353c4ab40211ad5cc7243256292b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-arrow-gen.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var arrow; + +var iterCount = 0; +async function * fn() { + for await ([ arrow = () => {} ] of [[]]) { + assert.sameValue(arrow.name, 'arrow'); + verifyNotEnumerable(arrow, 'name'); + verifyNotWritable(arrow, 'name'); + verifyConfigurable(arrow, 'name'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-class-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-class-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..bfa07d1986edf3ce552010c9c7837b141b41b047 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-class-gen.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-class-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [class, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xCls, cls, xCls2; + +var iterCount = 0; +async function * fn() { + for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) { + assert(xCls.name !== 'xCls'); + assert(xCls2.name !== 'xCls2'); + + assert.sameValue(cls.name, 'cls'); + verifyNotEnumerable(cls, 'name'); + verifyNotWritable(cls, 'name'); + verifyConfigurable(cls, 'name'); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..6d3002df707d302798f8249ccf75d216ef922f67 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-init-fn-name-gen.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + [...] 7. If Initializer is present and value is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be HasOwnProperty(v, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(v, + GetReferencedName(lref)). + +---*/ +var xGen, gen; + +var iterCount = 0; +async function * fn() { + for await ([ xGen = function* x() {}, gen = function*() {} ] of [[]]) { + assert.notSameValue(xGen.name, 'xGen'); + + assert.sameValue(gen.name, 'gen'); + verifyNotEnumerable(gen, 'name'); + verifyNotWritable(gen, 'name'); + verifyConfigurable(gen, 'name'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close-skip.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close-skip.js new file mode 100644 index 0000000000000000000000000000000000000000..8a4a11adf82c5146ec96aa67ad30dba6ef4ee5c8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close-skip.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: IteratorClose is not called when assignment evaluation has exhausted the iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). + 6. Return result. + +---*/ +var nextCount = 0; +var returnCount = 0; +var _; +var iterable = {}; +var iterator = { + next: function() { + nextCount += 1; + return { done: true }; + }, + return: function() { + returnCount += 1; + return {}; + } +}; +iterable[Symbol.iterator] = function() { + return iterator; +}; + +var iterCount = 0; +async function * fn() { + for await ([ _ ] of [iterable]) { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 0); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close.js new file mode 100644 index 0000000000000000000000000000000000000000..767e1b4c0ee03481223f39b82cf586809222892f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-iter-nrml-close.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: IteratorClose is called when assignment evaluation has not exhausted the iterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] + + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + result). + 6. Return result. + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 6. Let innerResult be Call(return, iterator, « »). + [...] + +---*/ +var nextCount = 0; +var returnCount = 0; +var thisValue = null; +var args = null; +var _; +var iterable = {}; +var iterator = { + next: function() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return: function() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +iterable[Symbol.iterator] = function() { + return iterator; +}; + +var iterCount = 0; +async function * fn() { + for await ([ _ ] of [iterable]) { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(thisValue, iterator, 'correct `this` value'); + assert(!!args, 'arguments object provided'); + assert.sameValue(args.length, 0, 'zero arguments specified'); + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..3f164e74f6a4574b4ac9b665e0cb0266a79572ec --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-gen.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-obj-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; + +var iterCount = 0; +async function * fn() { + for await ([{ x }] of [[{ x: 2 }]]) { + assert.sameValue(x, 2); + + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-yield-expr.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-yield-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..b23b78e865d795af24948b7e93a37fc47ef418b1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-nested-obj-yield-expr.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it behaves as a YieldExpression. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var iter, x; + + + +var iterCount = 0; +async function * fn() { + for await ([{ x = yield }] of [[{}]]) { + + iterCount += 1; + } +} + + + +iter = fn(); + +iter.next().then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(iterationResult => { + assert.sameValue(iterationResult.value, undefined); + assert.sameValue(iterationResult.done, true); + assert.sameValue(x, 4); + }).then($DONE, $DONE); +}); diff --git a/test/language/statements/for-await-of/async-gen-dstr-array-elem-put-unresolvable-no-strict-gen.js b/test/language/statements/for-await-of/async-gen-dstr-array-elem-put-unresolvable-no-strict-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..86647fda79ce60605d036211c939d39de2202bbd --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-array-elem-put-unresolvable-no-strict-gen.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict-gen.case +// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template +/*--- +description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, noStrict, async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +var iterCount = 0; +async function * fn() { + for await ([ unresolvable ] of [[]]) { + assert.sameValue(unresolvable, undefined); + + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE);