diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2017-05-31 15:46:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-31 15:46:40 -0400 |
commit | 60a6a7c81e99d83faf4b14be3f264b7a94e6882f (patch) | |
tree | 978f9f8dee230c9f296c707cf09c8d7650347301 /src | |
parent | e8fb452df81ac8c1e964a2ea000c5760414e77ac (diff) | |
parent | d4fde0a5c30829fb4393cbfe01f3e98c7cfb7c38 (diff) | |
download | qtdeclarative-testsuites-60a6a7c81e99d83faf4b14be3f264b7a94e6882f.tar.gz |
Merge pull request #1039 from rwaldron/dstr-assignment_for-await-of
[WIP] for-await-of: dstr-assignment, templates & cases
Diffstat (limited to 'src')
182 files changed, 5851 insertions, 0 deletions
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 000000000..d6e17a22f --- /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 000000000..85ec19f4a --- /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 000000000..d3cf8df24 --- /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 000000000..448124558 --- /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 000000000..348a1ced7 --- /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 000000000..d6d2d5702 --- /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 000000000..c05ff848f --- /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 000000000..70435eba4 --- /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 000000000..b25e02e03 --- /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 000000000..a11457512 --- /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 000000000..c5e33b303 --- /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 000000000..0d3cdfd55 --- /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 000000000..559a52fc2 --- /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 000000000..01b1ed2a1 --- /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 000000000..06ebf52f8 --- /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 000000000..3ca0ccc29 --- /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 000000000..d03a318ae --- /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 000000000..9391d1462 --- /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 000000000..55aa045ef --- /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 000000000..ff7953160 --- /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 000000000..71d03881c --- /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 000000000..c61cdc9a8 --- /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 000000000..7d2d69ddb --- /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 000000000..cee7a0558 --- /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 000000000..0b19e6788 --- /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 000000000..cba070d93 --- /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 000000000..1d322f0d2 --- /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 000000000..bf7e26e6c --- /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 000000000..6ec543b16 --- /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 000000000..7ccce4947 --- /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 000000000..c4b38e413 --- /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 000000000..24025d5cf --- /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 000000000..9dd7c5eb4 --- /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 000000000..7b2a81724 --- /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 000000000..19b426f71 --- /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 000000000..8d1e3e585 --- /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 000000000..6edca7faf --- /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 000000000..be16ef13a --- /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 000000000..41f922d2b --- /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 000000000..60709de65 --- /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 000000000..69a58f428 --- /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 000000000..67fde9884 --- /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 000000000..fdba045b9 --- /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 000000000..9d18ee63c --- /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 000000000..af3084436 --- /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 000000000..33b0acc19 --- /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 000000000..07d21bbb6 --- /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 000000000..0f9f8ed3c --- /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 000000000..a68cc95cb --- /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 000000000..0f796b4ea --- /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 000000000..d22bab44e --- /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 000000000..47f186696 --- /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 000000000..29f053d1a --- /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 000000000..96dd11cab --- /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 000000000..5b831a9de --- /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 000000000..835a6ad7d --- /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 000000000..0ae8bccca --- /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 000000000..5fcb2eacb --- /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 000000000..fe44dc090 --- /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 000000000..8669d0013 --- /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 000000000..d1828dc29 --- /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 000000000..04f371d5a --- /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 000000000..284200130 --- /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 000000000..7b8971233 --- /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 000000000..bb0412707 --- /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 000000000..c01dd08a5 --- /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 000000000..892f618f8 --- /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 000000000..c283de7cb --- /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 000000000..69681bac1 --- /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 000000000..7edf63e32 --- /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 000000000..b4093905f --- /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 000000000..24817be11 --- /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 000000000..c7dba9e14 --- /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 000000000..36136e581 --- /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 000000000..7f9aaf764 --- /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 000000000..6d6d18a3c --- /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 000000000..df52c9684 --- /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 000000000..5dd350dd4 --- /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 000000000..17f9c868c --- /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 000000000..297d7d4f7 --- /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 000000000..effa4f674 --- /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 000000000..e4e2cc80e --- /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 000000000..9949ba9ab --- /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 000000000..850a1162c --- /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 000000000..8cb676ff6 --- /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 000000000..6069e8969 --- /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 000000000..d3e60ed23 --- /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 000000000..d9edb6dc6 --- /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 000000000..2d9ae7b62 --- /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 000000000..fa38c07d1 --- /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 000000000..189381570 --- /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 000000000..fa864bc3d --- /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 000000000..9723b0243 --- /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 000000000..110ba07bf --- /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 000000000..12841d7d6 --- /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 000000000..c24803059 --- /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 000000000..0a2daa2d5 --- /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 000000000..4af124f33 --- /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 000000000..f7221ff11 --- /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 000000000..acc1dcb79 --- /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 000000000..9d3319a38 --- /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 000000000..31f598a06 --- /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 000000000..1fc6dbcd6 --- /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 000000000..31f598a06 --- /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 000000000..70c488d46 --- /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 000000000..a6d537c9e --- /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 000000000..90fe373fb --- /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 000000000..0fd7dffec --- /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 000000000..47425432f --- /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 000000000..b7515ae58 --- /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 000000000..de4246360 --- /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 000000000..aa4e88ed1 --- /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 000000000..2531e7af9 --- /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 000000000..6dff90413 --- /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 000000000..2e7f0ffbe --- /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 000000000..891a39bf9 --- /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 000000000..e587e08cb --- /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 000000000..e18d98745 --- /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 000000000..baff69ebd --- /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 000000000..35af6aaad --- /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 000000000..363aa9efc --- /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 000000000..135149127 --- /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 000000000..2eaea90f4 --- /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 000000000..be1928c8b --- /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 000000000..ffac568e7 --- /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 000000000..36e269e86 --- /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 000000000..3f398fa41 --- /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 000000000..7c931ef72 --- /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 000000000..da5c52c5b --- /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 000000000..548ede4be --- /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 000000000..a5c60545b --- /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 000000000..badf346f9 --- /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 000000000..dbd2aaaed --- /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 000000000..c7d2db9c9 --- /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 000000000..ea28e25fa --- /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 000000000..bbff2331c --- /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 000000000..444385fd3 --- /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 000000000..0c41d3a32 --- /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 000000000..575026770 --- /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 000000000..947dbcd2a --- /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 000000000..cdca15202 --- /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 000000000..1fe46df94 --- /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 000000000..a5ba2e3a0 --- /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 000000000..dc28778da --- /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 000000000..bb4478d34 --- /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 000000000..b9f7fc89c --- /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 000000000..ebde862cb --- /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 000000000..0d01eb80f --- /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 000000000..b06c24651 --- /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 000000000..10f4b5479 --- /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 000000000..04f903896 --- /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 000000000..226bdc79f --- /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 000000000..3efb3d355 --- /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 000000000..fec596e5a --- /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 000000000..f78417284 --- /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 000000000..c38a146ce --- /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 000000000..e40d850af --- /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 000000000..32748683b --- /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 000000000..5ebe36ddd --- /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 000000000..daa41735e --- /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 000000000..4124cd5a3 --- /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 000000000..5d6f65813 --- /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 000000000..12ee4ff1e --- /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 000000000..ad84d95b1 --- /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 000000000..3e1bbaffb --- /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 000000000..1e2f676de --- /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 000000000..cdcebfb97 --- /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 000000000..b61100602 --- /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 000000000..9cc4fe330 --- /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 000000000..6a3b38a22 --- /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 000000000..716958f7e --- /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 000000000..e2b18b84b --- /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 000000000..44bfa8e7b --- /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 000000000..e804894b2 --- /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 000000000..4906ffbb3 --- /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 000000000..a38daa7a9 --- /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 000000000..ef575bf55 --- /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 000000000..4feed1a46 --- /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 000000000..d5db125a0 --- /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 000000000..fff09d20e --- /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 000000000..f959b8bbd --- /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 000000000..541520c4a --- /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); |