diff options
Diffstat (limited to 'src')
300 files changed, 8593 insertions, 7 deletions
diff --git a/src/dstr-assignment-for-await/array-elem-init-assignment.case b/src/dstr-assignment-for-await/array-elem-init-assignment.case new file mode 100644 index 000000000..d6e17a22f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-evaluation.case b/src/dstr-assignment-for-await/array-elem-init-evaluation.case new file mode 100644 index 000000000..85ec19f4a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-fn-name-arrow.case b/src/dstr-assignment-for-await/array-elem-init-fn-name-arrow.case new file mode 100644 index 000000000..d3cf8df24 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-fn-name-class.case b/src/dstr-assignment-for-await/array-elem-init-fn-name-class.case new file mode 100644 index 000000000..448124558 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-fn-name-cover.case b/src/dstr-assignment-for-await/array-elem-init-fn-name-cover.case new file mode 100644 index 000000000..348a1ced7 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-fn-name-fn.case b/src/dstr-assignment-for-await/array-elem-init-fn-name-fn.case new file mode 100644 index 000000000..d6d2d5702 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-fn-name-gen.case b/src/dstr-assignment-for-await/array-elem-init-fn-name-gen.case new file mode 100644 index 000000000..c05ff848f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-in.case b/src/dstr-assignment-for-await/array-elem-init-in.case new file mode 100644 index 000000000..70435eba4 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-let.case b/src/dstr-assignment-for-await/array-elem-init-let.case new file mode 100644 index 000000000..b25e02e03 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-order.case b/src/dstr-assignment-for-await/array-elem-init-order.case new file mode 100644 index 000000000..a11457512 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-simple-no-strict.case b/src/dstr-assignment-for-await/array-elem-init-simple-no-strict.case new file mode 100644 index 000000000..c5e33b303 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-yield-expr.case b/src/dstr-assignment-for-await/array-elem-init-yield-expr.case new file mode 100644 index 000000000..0d3cdfd55 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-yield-ident-invalid.case b/src/dstr-assignment-for-await/array-elem-init-yield-ident-invalid.case new file mode 100644 index 000000000..559a52fc2 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-init-yield-ident-valid.case b/src/dstr-assignment-for-await/array-elem-init-yield-ident-valid.case new file mode 100644 index 000000000..01b1ed2a1 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-get-err.case b/src/dstr-assignment-for-await/array-elem-iter-get-err.case new file mode 100644 index 000000000..06ebf52f8 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-nrml-close-err.case b/src/dstr-assignment-for-await/array-elem-iter-nrml-close-err.case new file mode 100644 index 000000000..3ca0ccc29 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-nrml-close-null.case b/src/dstr-assignment-for-await/array-elem-iter-nrml-close-null.case new file mode 100644 index 000000000..d03a318ae --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-nrml-close-skip.case b/src/dstr-assignment-for-await/array-elem-iter-nrml-close-skip.case new file mode 100644 index 000000000..9391d1462 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-nrml-close.case b/src/dstr-assignment-for-await/array-elem-iter-nrml-close.case new file mode 100644 index 000000000..55aa045ef --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-rtrn-close-null.case b/src/dstr-assignment-for-await/array-elem-iter-rtrn-close-null.case new file mode 100644 index 000000000..ff7953160 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-iter-thrw-close-skip.case b/src/dstr-assignment-for-await/array-elem-iter-thrw-close-skip.case new file mode 100644 index 000000000..71d03881c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-invalid.case b/src/dstr-assignment-for-await/array-elem-nested-array-invalid.case new file mode 100644 index 000000000..c61cdc9a8 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-null.case b/src/dstr-assignment-for-await/array-elem-nested-array-null.case new file mode 100644 index 000000000..7d2d69ddb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-undefined-hole.case b/src/dstr-assignment-for-await/array-elem-nested-array-undefined-hole.case new file mode 100644 index 000000000..cee7a0558 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-undefined-own.case b/src/dstr-assignment-for-await/array-elem-nested-array-undefined-own.case new file mode 100644 index 000000000..0b19e6788 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-undefined.case b/src/dstr-assignment-for-await/array-elem-nested-array-undefined.case new file mode 100644 index 000000000..cba070d93 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-yield-expr.case b/src/dstr-assignment-for-await/array-elem-nested-array-yield-expr.case new file mode 100644 index 000000000..1d322f0d2 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-yield-ident-invalid.case b/src/dstr-assignment-for-await/array-elem-nested-array-yield-ident-invalid.case new file mode 100644 index 000000000..bf7e26e6c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array-yield-ident-valid.case b/src/dstr-assignment-for-await/array-elem-nested-array-yield-ident-valid.case new file mode 100644 index 000000000..6ec543b16 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-array.case b/src/dstr-assignment-for-await/array-elem-nested-array.case new file mode 100644 index 000000000..7ccce4947 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-invalid.case b/src/dstr-assignment-for-await/array-elem-nested-obj-invalid.case new file mode 100644 index 000000000..c4b38e413 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-null.case b/src/dstr-assignment-for-await/array-elem-nested-obj-null.case new file mode 100644 index 000000000..24025d5cf --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-undefined-hole.case b/src/dstr-assignment-for-await/array-elem-nested-obj-undefined-hole.case new file mode 100644 index 000000000..9dd7c5eb4 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-undefined-own.case b/src/dstr-assignment-for-await/array-elem-nested-obj-undefined-own.case new file mode 100644 index 000000000..7b2a81724 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-undefined.case b/src/dstr-assignment-for-await/array-elem-nested-obj-undefined.case new file mode 100644 index 000000000..19b426f71 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-yield-expr.case b/src/dstr-assignment-for-await/array-elem-nested-obj-yield-expr.case new file mode 100644 index 000000000..8d1e3e585 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-yield-ident-invalid.case b/src/dstr-assignment-for-await/array-elem-nested-obj-yield-ident-invalid.case new file mode 100644 index 000000000..6edca7faf --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj-yield-ident-valid.case b/src/dstr-assignment-for-await/array-elem-nested-obj-yield-ident-valid.case new file mode 100644 index 000000000..be16ef13a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-nested-obj.case b/src/dstr-assignment-for-await/array-elem-nested-obj.case new file mode 100644 index 000000000..41f922d2b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-const.case b/src/dstr-assignment-for-await/array-elem-put-const.case new file mode 100644 index 000000000..60709de65 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-let.case b/src/dstr-assignment-for-await/array-elem-put-let.case new file mode 100644 index 000000000..69a58f428 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-prop-ref-no-get.case b/src/dstr-assignment-for-await/array-elem-put-prop-ref-no-get.case new file mode 100644 index 000000000..67fde9884 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-prop-ref-user-err.case b/src/dstr-assignment-for-await/array-elem-put-prop-ref-user-err.case new file mode 100644 index 000000000..fdba045b9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-prop-ref.case b/src/dstr-assignment-for-await/array-elem-put-prop-ref.case new file mode 100644 index 000000000..9d18ee63c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-unresolvable-no-strict.case b/src/dstr-assignment-for-await/array-elem-put-unresolvable-no-strict.case new file mode 100644 index 000000000..af3084436 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-put-unresolvable-strict.case b/src/dstr-assignment-for-await/array-elem-put-unresolvable-strict.case new file mode 100644 index 000000000..33b0acc19 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-identifier.case b/src/dstr-assignment-for-await/array-elem-target-identifier.case new file mode 100644 index 000000000..07d21bbb6 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-simple-no-strict.case b/src/dstr-assignment-for-await/array-elem-target-simple-no-strict.case new file mode 100644 index 000000000..0f9f8ed3c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-simple-strict.case b/src/dstr-assignment-for-await/array-elem-target-simple-strict.case new file mode 100644 index 000000000..a68cc95cb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-yield-expr.case b/src/dstr-assignment-for-await/array-elem-target-yield-expr.case new file mode 100644 index 000000000..0f796b4ea --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-yield-invalid.case b/src/dstr-assignment-for-await/array-elem-target-yield-invalid.case new file mode 100644 index 000000000..d22bab44e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-target-yield-valid.case b/src/dstr-assignment-for-await/array-elem-target-yield-valid.case new file mode 100644 index 000000000..47f186696 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-elision-iter-abpt.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-abpt.case new file mode 100644 index 000000000..29f053d1a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-elision-iter-nrml-close-err.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-err.case new file mode 100644 index 000000000..96dd11cab --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-elision-iter-nrml-close-null.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-null.case new file mode 100644 index 000000000..5b831a9de --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-elision-iter-nrml-close-skip.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-skip.case new file mode 100644 index 000000000..835a6ad7d --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-elision-iter-nrml-close.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close.case new file mode 100644 index 000000000..0ae8bccca --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-get-err.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-get-err.case new file mode 100644 index 000000000..5fcb2eacb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-nrml-close-err.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close-err.case new file mode 100644 index 000000000..fe44dc090 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-nrml-close-null.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close-null.case new file mode 100644 index 000000000..8669d0013 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-nrml-close-skip.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close-skip.case new file mode 100644 index 000000000..d1828dc29 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-nrml-close.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close.case new file mode 100644 index 000000000..04f371d5a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-rtrn-close-err.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-rtrn-close-err.case new file mode 100644 index 000000000..284200130 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-rtrn-close-null.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-rtrn-close-null.case new file mode 100644 index 000000000..7b8971233 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-rtrn-close.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-rtrn-close.case new file mode 100644 index 000000000..bb0412707 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-list-thrw-close-skip.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-list-thrw-close-skip.case new file mode 100644 index 000000000..c01dd08a5 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-rest-nrml-close-skip.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-rest-nrml-close-skip.case new file mode 100644 index 000000000..892f618f8 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-rest-rtrn-close-err.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-rest-rtrn-close-err.case new file mode 100644 index 000000000..c283de7cb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elem-trlg-iter-rest-rtrn-close-null.case b/src/dstr-assignment-for-await/array-elem-trlg-iter-rest-rtrn-close-null.case new file mode 100644 index 000000000..69681bac1 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elision-iter-nrml-close-skip.case b/src/dstr-assignment-for-await/array-elision-iter-nrml-close-skip.case new file mode 100644 index 000000000..7edf63e32 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elision-iter-nrml-close.case b/src/dstr-assignment-for-await/array-elision-iter-nrml-close.case new file mode 100644 index 000000000..b4093905f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elision-val-array.case b/src/dstr-assignment-for-await/array-elision-val-array.case new file mode 100644 index 000000000..24817be11 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-elision-val-string.case b/src/dstr-assignment-for-await/array-elision-val-string.case new file mode 100644 index 000000000..c7dba9e14 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-empty-iter-close.case b/src/dstr-assignment-for-await/array-empty-iter-close.case new file mode 100644 index 000000000..36136e581 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-empty-val-array.case b/src/dstr-assignment-for-await/array-empty-val-array.case new file mode 100644 index 000000000..7f9aaf764 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-empty-val-string.case b/src/dstr-assignment-for-await/array-empty-val-string.case new file mode 100644 index 000000000..6d6d18a3c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-after-element.case b/src/dstr-assignment-for-await/array-rest-after-element.case new file mode 100644 index 000000000..df52c9684 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-after-elision.case b/src/dstr-assignment-for-await/array-rest-after-elision.case new file mode 100644 index 000000000..5dd350dd4 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-elision.case b/src/dstr-assignment-for-await/array-rest-elision.case new file mode 100644 index 000000000..17f9c868c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-iter-nrml-close-skip.case b/src/dstr-assignment-for-await/array-rest-iter-nrml-close-skip.case new file mode 100644 index 000000000..297d7d4f7 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-iteration.case b/src/dstr-assignment-for-await/array-rest-iteration.case new file mode 100644 index 000000000..effa4f674 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-lref.case b/src/dstr-assignment-for-await/array-rest-lref.case new file mode 100644 index 000000000..e4e2cc80e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-null.case b/src/dstr-assignment-for-await/array-rest-nested-array-null.case new file mode 100644 index 000000000..9949ba9ab --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-undefined-hole.case b/src/dstr-assignment-for-await/array-rest-nested-array-undefined-hole.case new file mode 100644 index 000000000..850a1162c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-undefined-own.case b/src/dstr-assignment-for-await/array-rest-nested-array-undefined-own.case new file mode 100644 index 000000000..8cb676ff6 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-undefined.case b/src/dstr-assignment-for-await/array-rest-nested-array-undefined.case new file mode 100644 index 000000000..6069e8969 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-yield-expr.case b/src/dstr-assignment-for-await/array-rest-nested-array-yield-expr.case new file mode 100644 index 000000000..d3e60ed23 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array-yield-ident-valid.case b/src/dstr-assignment-for-await/array-rest-nested-array-yield-ident-valid.case new file mode 100644 index 000000000..d9edb6dc6 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-array.case b/src/dstr-assignment-for-await/array-rest-nested-array.case new file mode 100644 index 000000000..2d9ae7b62 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-null.case b/src/dstr-assignment-for-await/array-rest-nested-obj-null.case new file mode 100644 index 000000000..fa38c07d1 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-undefined-hole.case b/src/dstr-assignment-for-await/array-rest-nested-obj-undefined-hole.case new file mode 100644 index 000000000..189381570 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-undefined-own.case b/src/dstr-assignment-for-await/array-rest-nested-obj-undefined-own.case new file mode 100644 index 000000000..fa864bc3d --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-undefined.case b/src/dstr-assignment-for-await/array-rest-nested-obj-undefined.case new file mode 100644 index 000000000..9723b0243 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-yield-expr.case b/src/dstr-assignment-for-await/array-rest-nested-obj-yield-expr.case new file mode 100644 index 000000000..110ba07bf --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj-yield-ident-valid.case b/src/dstr-assignment-for-await/array-rest-nested-obj-yield-ident-valid.case new file mode 100644 index 000000000..12841d7d6 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-nested-obj.case b/src/dstr-assignment-for-await/array-rest-nested-obj.case new file mode 100644 index 000000000..c24803059 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-put-prop-ref-no-get.case b/src/dstr-assignment-for-await/array-rest-put-prop-ref-no-get.case new file mode 100644 index 000000000..0a2daa2d5 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-put-prop-ref.case b/src/dstr-assignment-for-await/array-rest-put-prop-ref.case new file mode 100644 index 000000000..4af124f33 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-put-unresolvable-no-strict.case b/src/dstr-assignment-for-await/array-rest-put-unresolvable-no-strict.case new file mode 100644 index 000000000..f7221ff11 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-yield-expr.case b/src/dstr-assignment-for-await/array-rest-yield-expr.case new file mode 100644 index 000000000..acc1dcb79 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/array-rest-yield-ident-valid.case b/src/dstr-assignment-for-await/array-rest-yield-ident-valid.case new file mode 100644 index 000000000..9d3319a38 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/async-function/async-func-decl.template b/src/dstr-assignment-for-await/async-function/async-func-decl.template new file mode 100644 index 000000000..31f598a06 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/async-generator/async-gen-decl.template b/src/dstr-assignment-for-await/async-generator/async-gen-decl.template new file mode 100644 index 000000000..1fc6dbcd6 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/default/async-func-decl.template b/src/dstr-assignment-for-await/default/async-func-decl.template new file mode 100644 index 000000000..31f598a06 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/default/async-gen-decl.template b/src/dstr-assignment-for-await/default/async-gen-decl.template new file mode 100644 index 000000000..70c488d46 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/error-async-function-syntax/async-func-decl.template b/src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template new file mode 100644 index 000000000..a6d537c9e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/error-async-generator-syntax/async-gen-decl.template b/src/dstr-assignment-for-await/error-async-generator-syntax/async-gen-decl.template new file mode 100644 index 000000000..90fe373fb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/error/async-func-decl.template b/src/dstr-assignment-for-await/error/async-func-decl.template new file mode 100644 index 000000000..0fd7dffec --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/error/async-gen-decl.template b/src/dstr-assignment-for-await/error/async-gen-decl.template new file mode 100644 index 000000000..47425432f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-empty-bool.case b/src/dstr-assignment-for-await/obj-empty-bool.case new file mode 100644 index 000000000..b7515ae58 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-empty-num.case b/src/dstr-assignment-for-await/obj-empty-num.case new file mode 100644 index 000000000..de4246360 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-empty-obj.case b/src/dstr-assignment-for-await/obj-empty-obj.case new file mode 100644 index 000000000..aa4e88ed1 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-empty-string.case b/src/dstr-assignment-for-await/obj-empty-string.case new file mode 100644 index 000000000..2531e7af9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-empty-symbol.case b/src/dstr-assignment-for-await/obj-empty-symbol.case new file mode 100644 index 000000000..6dff90413 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-identifier-resolution-first.case b/src/dstr-assignment-for-await/obj-id-identifier-resolution-first.case new file mode 100644 index 000000000..2e7f0ffbe --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-identifier-resolution-last.case b/src/dstr-assignment-for-await/obj-id-identifier-resolution-last.case new file mode 100644 index 000000000..891a39bf9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-identifier-resolution-lone.case b/src/dstr-assignment-for-await/obj-id-identifier-resolution-lone.case new file mode 100644 index 000000000..e587e08cb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-identifier-resolution-middle.case b/src/dstr-assignment-for-await/obj-id-identifier-resolution-middle.case new file mode 100644 index 000000000..e18d98745 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-identifier-resolution-trlng.case b/src/dstr-assignment-for-await/obj-id-identifier-resolution-trlng.case new file mode 100644 index 000000000..baff69ebd --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-assignment-missing.case b/src/dstr-assignment-for-await/obj-id-init-assignment-missing.case new file mode 100644 index 000000000..35af6aaad --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-assignment-null.case b/src/dstr-assignment-for-await/obj-id-init-assignment-null.case new file mode 100644 index 000000000..363aa9efc --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-assignment-truthy.case b/src/dstr-assignment-for-await/obj-id-init-assignment-truthy.case new file mode 100644 index 000000000..135149127 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-assignment-undef.case b/src/dstr-assignment-for-await/obj-id-init-assignment-undef.case new file mode 100644 index 000000000..2eaea90f4 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-evaluation.case b/src/dstr-assignment-for-await/obj-id-init-evaluation.case new file mode 100644 index 000000000..be1928c8b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-fn-name-arrow.case b/src/dstr-assignment-for-await/obj-id-init-fn-name-arrow.case new file mode 100644 index 000000000..ffac568e7 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-fn-name-class.case b/src/dstr-assignment-for-await/obj-id-init-fn-name-class.case new file mode 100644 index 000000000..36e269e86 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-fn-name-cover.case b/src/dstr-assignment-for-await/obj-id-init-fn-name-cover.case new file mode 100644 index 000000000..3f398fa41 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-fn-name-fn.case b/src/dstr-assignment-for-await/obj-id-init-fn-name-fn.case new file mode 100644 index 000000000..7c931ef72 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-fn-name-gen.case b/src/dstr-assignment-for-await/obj-id-init-fn-name-gen.case new file mode 100644 index 000000000..da5c52c5b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-in.case b/src/dstr-assignment-for-await/obj-id-init-in.case new file mode 100644 index 000000000..548ede4be --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-order.case b/src/dstr-assignment-for-await/obj-id-init-order.case new file mode 100644 index 000000000..a5c60545b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-simple-no-strict.case b/src/dstr-assignment-for-await/obj-id-init-simple-no-strict.case new file mode 100644 index 000000000..badf346f9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-yield-expr.case b/src/dstr-assignment-for-await/obj-id-init-yield-expr.case new file mode 100644 index 000000000..dbd2aaaed --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-init-yield-ident-valid.case b/src/dstr-assignment-for-await/obj-id-init-yield-ident-valid.case new file mode 100644 index 000000000..c7d2db9c9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-put-unresolvable-no-strict.case b/src/dstr-assignment-for-await/obj-id-put-unresolvable-no-strict.case new file mode 100644 index 000000000..ea28e25fa --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-id-simple-no-strict.case b/src/dstr-assignment-for-await/obj-id-simple-no-strict.case new file mode 100644 index 000000000..bbff2331c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-assignment-missing.case b/src/dstr-assignment-for-await/obj-prop-elem-init-assignment-missing.case new file mode 100644 index 000000000..444385fd3 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-assignment-null.case b/src/dstr-assignment-for-await/obj-prop-elem-init-assignment-null.case new file mode 100644 index 000000000..0c41d3a32 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-assignment-truthy.case b/src/dstr-assignment-for-await/obj-prop-elem-init-assignment-truthy.case new file mode 100644 index 000000000..575026770 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-assignment-undef.case b/src/dstr-assignment-for-await/obj-prop-elem-init-assignment-undef.case new file mode 100644 index 000000000..947dbcd2a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-evaluation.case b/src/dstr-assignment-for-await/obj-prop-elem-init-evaluation.case new file mode 100644 index 000000000..cdca15202 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-fn-name-arrow.case b/src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-arrow.case new file mode 100644 index 000000000..1fe46df94 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-fn-name-class.case b/src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-class.case new file mode 100644 index 000000000..a5ba2e3a0 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-fn-name-cover.case b/src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-cover.case new file mode 100644 index 000000000..dc28778da --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-fn-name-fn.case b/src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-fn.case new file mode 100644 index 000000000..bb4478d34 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-fn-name-gen.case b/src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-gen.case new file mode 100644 index 000000000..b9f7fc89c --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-in.case b/src/dstr-assignment-for-await/obj-prop-elem-init-in.case new file mode 100644 index 000000000..ebde862cb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-yield-expr.case b/src/dstr-assignment-for-await/obj-prop-elem-init-yield-expr.case new file mode 100644 index 000000000..0d01eb80f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-init-yield-ident-valid.case b/src/dstr-assignment-for-await/obj-prop-elem-init-yield-ident-valid.case new file mode 100644 index 000000000..b06c24651 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-target-yield-expr.case b/src/dstr-assignment-for-await/obj-prop-elem-target-yield-expr.case new file mode 100644 index 000000000..10f4b5479 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-elem-target-yield-ident-valid.case b/src/dstr-assignment-for-await/obj-prop-elem-target-yield-ident-valid.case new file mode 100644 index 000000000..04f903896 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-identifier-resolution-first.case b/src/dstr-assignment-for-await/obj-prop-identifier-resolution-first.case new file mode 100644 index 000000000..226bdc79f --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-identifier-resolution-last.case b/src/dstr-assignment-for-await/obj-prop-identifier-resolution-last.case new file mode 100644 index 000000000..3efb3d355 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-identifier-resolution-lone.case b/src/dstr-assignment-for-await/obj-prop-identifier-resolution-lone.case new file mode 100644 index 000000000..fec596e5a --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-identifier-resolution-middle.case b/src/dstr-assignment-for-await/obj-prop-identifier-resolution-middle.case new file mode 100644 index 000000000..f78417284 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-identifier-resolution-trlng.case b/src/dstr-assignment-for-await/obj-prop-identifier-resolution-trlng.case new file mode 100644 index 000000000..c38a146ce --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-name-evaluation.case b/src/dstr-assignment-for-await/obj-prop-name-evaluation.case new file mode 100644 index 000000000..e40d850af --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-array-yield-expr.case b/src/dstr-assignment-for-await/obj-prop-nested-array-yield-expr.case new file mode 100644 index 000000000..32748683b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-array-yield-ident-valid.case b/src/dstr-assignment-for-await/obj-prop-nested-array-yield-ident-valid.case new file mode 100644 index 000000000..5ebe36ddd --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-array.case b/src/dstr-assignment-for-await/obj-prop-nested-array.case new file mode 100644 index 000000000..daa41735e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-obj-yield-expr.case b/src/dstr-assignment-for-await/obj-prop-nested-obj-yield-expr.case new file mode 100644 index 000000000..4124cd5a3 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-obj-yield-ident-valid.case b/src/dstr-assignment-for-await/obj-prop-nested-obj-yield-ident-valid.case new file mode 100644 index 000000000..5d6f65813 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-nested-obj.case b/src/dstr-assignment-for-await/obj-prop-nested-obj.case new file mode 100644 index 000000000..12ee4ff1e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-put-order.case b/src/dstr-assignment-for-await/obj-prop-put-order.case new file mode 100644 index 000000000..ad84d95b1 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-put-prop-ref-no-get.case b/src/dstr-assignment-for-await/obj-prop-put-prop-ref-no-get.case new file mode 100644 index 000000000..3e1bbaffb --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-put-prop-ref.case b/src/dstr-assignment-for-await/obj-prop-put-prop-ref.case new file mode 100644 index 000000000..1e2f676de --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-prop-put-unresolvable-no-strict.case b/src/dstr-assignment-for-await/obj-prop-put-unresolvable-no-strict.case new file mode 100644 index 000000000..cdcebfb97 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-descriptors.case b/src/dstr-assignment-for-await/obj-rest-descriptors.case new file mode 100644 index 000000000..b61100602 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-empty-obj.case b/src/dstr-assignment-for-await/obj-rest-empty-obj.case new file mode 100644 index 000000000..9cc4fe330 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-getter.case b/src/dstr-assignment-for-await/obj-rest-getter.case new file mode 100644 index 000000000..6a3b38a22 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-nested-obj-nested-rest.case b/src/dstr-assignment-for-await/obj-rest-nested-obj-nested-rest.case new file mode 100644 index 000000000..716958f7e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-nested-obj.case b/src/dstr-assignment-for-await/obj-rest-nested-obj.case new file mode 100644 index 000000000..e2b18b84b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-number.case b/src/dstr-assignment-for-await/obj-rest-number.case new file mode 100644 index 000000000..44bfa8e7b --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-obj-own-property.case b/src/dstr-assignment-for-await/obj-rest-obj-own-property.case new file mode 100644 index 000000000..e804894b2 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-same-name.case b/src/dstr-assignment-for-await/obj-rest-same-name.case new file mode 100644 index 000000000..4906ffbb3 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-skip-non-enumerable.case b/src/dstr-assignment-for-await/obj-rest-skip-non-enumerable.case new file mode 100644 index 000000000..a38daa7a9 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-str-val.case b/src/dstr-assignment-for-await/obj-rest-str-val.case new file mode 100644 index 000000000..ef575bf55 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-symbol-val.case b/src/dstr-assignment-for-await/obj-rest-symbol-val.case new file mode 100644 index 000000000..4feed1a46 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-to-property-with-setter.case b/src/dstr-assignment-for-await/obj-rest-to-property-with-setter.case new file mode 100644 index 000000000..d5db125a0 --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-to-property.case b/src/dstr-assignment-for-await/obj-rest-to-property.case new file mode 100644 index 000000000..fff09d20e --- /dev/null +++ b/src/dstr-assignment-for-await/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-for-await/obj-rest-valid-object.case b/src/dstr-assignment-for-await/obj-rest-valid-object.case new file mode 100644 index 000000000..f959b8bbd --- /dev/null +++ b/src/dstr-assignment-for-await/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-binding-for-await/ary-init-iter-close.case b/src/dstr-binding-for-await/ary-init-iter-close.case new file mode 100644 index 000000000..860a773bf --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-close.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: Iterator is closed when not exhausted by pattern evaluation +template: default +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] +features: [Symbol.iterator] +---*/ + +//- setup +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return { value: null, done: false }; + }, + return() { + doneCallCount += 1; + return {}; + } + }; +}; +//- elems +[x] +//- vals +iter +//- body +assert.sameValue(doneCallCount, 1); diff --git a/src/dstr-binding-for-await/ary-init-iter-get-err.case b/src/dstr-binding-for-await/ary-init-iter-get-err.case new file mode 100644 index 000000000..1ac51278b --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-get-err.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: Abrupt completion returned by GetIterator +template: error +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be ? GetIterator(value). +features: [Symbol.iterator] +---*/ + +//- setup +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; +//- elems +[x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-init-iter-no-close.case b/src/dstr-binding-for-await/ary-init-iter-no-close.case new file mode 100644 index 000000000..8184d2f2e --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-no-close.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: Iterator is not closed when exhausted by pattern evaluation +template: default +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] +features: [Symbol.iterator] +---*/ + +//- setup +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return { value: null, done: true }; + }, + return() { + doneCallCount += 1; + return {}; + } + }; +}; +//- elems +[x] +//- vals +iter +//- body +assert.sameValue(doneCallCount, 0); diff --git a/src/dstr-binding-for-await/ary-name-iter-val.case b/src/dstr-binding-for-await/ary-name-iter-val.case new file mode 100644 index 000000000..624994f47 --- /dev/null +++ b/src/dstr-binding-for-await/ary-name-iter-val.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: SingleNameBinding with normal value iteration +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case new file mode 100644 index 000000000..ae00dace2 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.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: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[[x, y, z] = [4, 5, 6]] +//- vals +[] +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case new file mode 100644 index 000000000..cb561cf1b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.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: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[[x, y, z] = [4, 5, 6]] +//- vals +[[7, 8, 9]] +//- body +assert.sameValue(x, 7); +assert.sameValue(y, 8); +assert.sameValue(z, 9); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case new file mode 100644 index 000000000..e09a765c7 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.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: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[[,] = g()] +//- vals +[] +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case new file mode 100644 index 000000000..96f07a6d1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.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: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +features: [generators] +---*/ + +//- setup +var callCount = 0; +function* g() { + callCount += 1; +}; +//- elems +[[,] = g()] +//- vals +[[]] +//- body +assert.sameValue(callCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case new file mode 100644 index 000000000..fcec666f2 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.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: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- setup +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); +//- elems +[[] = function() { initCount += 1; return iter; }()] +//- vals +[] +//- body +assert.sameValue(initCount, 1); +assert.sameValue(iterCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case new file mode 100644 index 000000000..c88783d15 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.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: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- setup +var initCount = 0; +//- elems +[[] = function() { initCount += 1; }()] +//- vals +[[23]] +//- body +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case new file mode 100644 index 000000000..59f46ff49 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.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: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- setup +var values = [2, 1, 3]; +//- elems +[[...x] = values] +//- vals +[] +//- body +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case new file mode 100644 index 000000000..b7269eac1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.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: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- setup +var values = [2, 1, 3]; +var initCount = 0; +//- elems +[[...x] = function() { initCount += 1; }()] +//- vals +[values] +//- body +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case new file mode 100644 index 000000000..633f880f9 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.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: Nested array destructuring with a null value +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be ? GetIterator(value). +---*/ + +//- elems +[[x]] +//- vals +[null] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case new file mode 100644 index 000000000..df82792fe --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.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: Destructuring initializer with an exhausted iterator +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[] +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case new file mode 100644 index 000000000..23001a4dd --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.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: SingleNameBinding does assign name to arrow functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[arrow = () => {}] +//- vals +[] +//- body +assert.sameValue(arrow.name, 'arrow'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case new file mode 100644 index 000000000..4185a236b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.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: SingleNameBinding assigns `name` to "anonymous" classes +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] +//- vals +[] +//- body +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case new file mode 100644 index 000000000..e466b2b04 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.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: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[cover = (function () {}), xCover = (0, function() {})] +//- vals +[] +//- body +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case new file mode 100644 index 000000000..e537c02c8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.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: SingleNameBinding assigns name to "anonymous" functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[fn = function () {}, xFn = function x() {}] +//- vals +[] +//- body +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case new file mode 100644 index 000000000..5b1736e88 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.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: SingleNameBinding assigns name to "anonymous" generator functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[gen = function* () {}, xGen = function* x() {}] +//- vals +[] +//- body +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case new file mode 100644 index 000000000..a234fffd8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.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: Destructuring initializer with a "hole" +template: default +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[,] +//- body +assert.sameValue(x, 23); +// another statement diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case new file mode 100644 index 000000000..84cf03cf4 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.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: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +[w = counter(), x = counter(), y = counter(), z = counter()] +//- vals +[null, 0, false, ''] +//- body +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case new file mode 100644 index 000000000..f4eb856aa --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.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: Destructuring initializer returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). +---*/ + +//- elems +[x = (function() { throw new Test262Error(); })()] +//- vals +[undefined] +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case new file mode 100644 index 000000000..3cbf54138 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-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: Destructuring initializer with an undefined value +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[undefined] +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case new file mode 100644 index 000000000..9dc9bf8f4 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.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: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.1 GetValue ( V ) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +//- elems +[ x = unresolvableReference ] +//- vals +[] +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case new file mode 100644 index 000000000..de40bed9e --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.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: SingleNameBinding when value iteration completes +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x] +//- vals +[] +//- body +assert.sameValue(x, undefined); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case new file mode 100644 index 000000000..e21fb9eaf --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.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: SingleNameBinding when value iteration was completed previously +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[_, x] +//- vals +[] +//- body +assert.sameValue(x, undefined); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case new file mode 100644 index 000000000..34faa9e14 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-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: Error forwarding when IteratorStep returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ + +//- setup +var g = {}; +g[Symbol.iterator] = function() { + return { + next() { + throw new Test262Error(); + } + }; +}; +//- elems +[x] +//- vals +g +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case new file mode 100644 index 000000000..d87224a32 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case @@ -0,0 +1,43 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Error forwarding when IteratorValue returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ + +//- setup +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next() { + return poisonedValue; + } + }; +}; +//- elems +[x] +//- vals +g +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case new file mode 100644 index 000000000..364ffa6fb --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.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: SingleNameBinding when value iteration was completed previously +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case new file mode 100644 index 000000000..b3be0967b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.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: BindingElement with object binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[{ x, y, z } = { x: 44, y: 55, z: 66 }] +//- vals +[] +//- body +assert.sameValue(x, 44); +assert.sameValue(y, 55); +assert.sameValue(z, 66); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case new file mode 100644 index 000000000..d6ca94ed3 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.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: BindingElement with object binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[{ x, y, z } = { x: 44, y: 55, z: 66 }] +//- vals +[{ x: 11, y: 22, z: 33 }] +//- body +assert.sameValue(x, 11); +assert.sameValue(y, 22); +assert.sameValue(z, 33); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case new file mode 100644 index 000000000..10887bd28 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.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: BindingElement with object binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] +//- vals +[] +//- body +assert.sameValue(v, 444); +assert.sameValue(x, 555); +assert.sameValue(z, 666); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case new file mode 100644 index 000000000..2c5bd0cbe --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.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: BindingElement with object binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +//- elems +[{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] +//- vals +[{ u: 777, w: 888, y: 999 }] +//- body +assert.sameValue(v, 777); +assert.sameValue(x, 888); +assert.sameValue(z, 999); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case new file mode 100644 index 000000000..bcdf94c98 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.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: Nested object destructuring with a null value +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +//- elems +[{ x }] +//- vals +[null] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case new file mode 100644 index 000000000..f3603bc0a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.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: Nested object destructuring with a value of `undefined` +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +//- elems +[{ x }] +//- vals +[] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case new file mode 100644 index 000000000..2d7cd5094 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.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: Elision accepts exhausted iterator +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). +features: [generator] +---*/ + +//- setup +var iter = function*() {}(); +iter.next(); +//- elems +[,] +//- vals +iter diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case b/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case new file mode 100644 index 000000000..18c0046a3 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: iter-close +desc: > + The iterator is properly consumed by the destructuring pattern +---*/ + +//- setup +const iter = (function* () { + yield; + yield; +})(); + +//- elems +[,] +//- iter +iter +//- assertions +assert.sameValue(iter.next().done, true, 'iteration occurred as expected'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-step-err.case b/src/dstr-binding-for-await/ary-ptrn-elision-step-err.case new file mode 100644 index 000000000..1f1d69448 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-step-err.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: Elision advances iterator and forwards abrupt completions +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +features: [generator] +---*/ + +//- setup +var following = 0; +var iter = function* () { + throw new Test262Error(); + following += 1; +}(); +//- elems +[,] +//- vals +iter +//- error +Test262Error +//- rejectBody +assert.sameValue(following, 0, "iterator is properly closed"); diff --git a/src/dstr-binding-for-await/ary-ptrn-elision.case b/src/dstr-binding-for-await/ary-ptrn-elision.case new file mode 100644 index 000000000..828e8413a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision.case @@ -0,0 +1,42 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Elision advances iterator +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). +features: [generator] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[,] +//- vals +g() +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-empty.case b/src/dstr-binding-for-await/ary-ptrn-empty.case new file mode 100644 index 000000000..6a348ea18 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-empty.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: No iteration occurs for an "empty" array binding pattern +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). +features: [generators] +---*/ + +//- setup +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); +//- elems +[] +//- vals +iter +//- body +assert.sameValue(iterations, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case new file mode 100644 index 000000000..79a93524c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.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. +/*--- +template: default +desc: Rest element containing an array BindingElementList pattern +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[...[x, y, z]] +//- vals +[3, 4, 5] +//- body +assert.sameValue(x, 3); +assert.sameValue(y, 4); +assert.sameValue(z, 5); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case new file mode 100644 index 000000000..d11cb7243 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.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. +/*--- +template: default +desc: Rest element containing an elision +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[...[,]] +//- vals +g() +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 1); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case new file mode 100644 index 000000000..bbaea3f56 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.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. +/*--- +template: default +desc: Rest element containing an "empty" array pattern +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). +features: [generators] +---*/ + +//- setup +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); +//- elems +[...[]] +//- vals +iter +//- body +assert.sameValue(iterations, 1); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case new file mode 100644 index 000000000..428687e1c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.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. +/*--- +template: default +desc: Rest element containing a rest element +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +//- setup +var values = [1, 2, 3]; +//- elems +[...[...x]] +//- vals +values +//- body +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); + diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case new file mode 100644 index 000000000..96ac1ad5a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.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. +/*--- +template: error +desc: Rest element following elision elements +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +features: [generators] +---*/ + +//- setup +var iter = (function*() { throw new Test262Error(); })(); +//- elems +[, ...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case new file mode 100644 index 000000000..0643b134d --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.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. +/*--- +template: default +desc: Rest element following elision elements +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ + +//- setup +var values = [1, 2, 3, 4, 5]; +//- elems +[ , , ...x] +//- vals +values +//- body +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 3); +assert.sameValue(x[1], 4); +assert.sameValue(x[2], 5); +assert.notSameValue(x, values); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case new file mode 100644 index 000000000..18ab5e958 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.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. +/*--- +template: default +desc: RestElement applied to an exhausted iterator +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). + 3. Let A be ArrayCreate(0). + 4. Let n=0. + 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). +features: [Symbol.iterator] +---*/ + +//- elems +[, , ...x] +//- vals +[1, 2] +//- body +assert(Array.isArray(x)); +assert.sameValue(x.length, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case new file mode 100644 index 000000000..2127b9eda --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: iter-close +desc: > + The iterator is properly consumed by the destructuring pattern +---*/ + +//- setup +const iter = (function* () { + yield; + yield; +})(); + +//- elems +[...x] +//- iter +iter +//- assertions +assert.sameValue(iter.next().done, true, 'iteration occurred as expected'); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case new file mode 100644 index 000000000..48b826f78 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.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. +/*--- +template: error +desc: Error forwarding when IteratorStep returns an abrupt completion +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). + 3. Let A be ArrayCreate(0). + 4. Let n=0. + 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); +//- elems +[...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case new file mode 100644 index 000000000..5912533b8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case @@ -0,0 +1,44 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error forwarding when IteratorValue returns an abrupt completion +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). + 3. Let A be ArrayCreate(0). + 4. Let n=0. + 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +//- setup +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return poisonedValue; + } + }; +}; +//- elems +[...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-id.case new file mode 100644 index 000000000..93ea865be --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id.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. +/*--- +template: default +desc: Lone rest element +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 3. Let A be ArrayCreate(0). + [...] + 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ + +//- setup +var values = [1, 2, 3]; +//- elems +[...x] +//- vals +values +//- body +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case new file mode 100644 index 000000000..8d302fa4c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.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. +/*--- +template: default +desc: Reset element (nested array pattern) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...[ x ] = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-init-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-id.case new file mode 100644 index 000000000..157935b1a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-id.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. +/*--- +template: default +desc: Reset element (identifier) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...x = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case new file mode 100644 index 000000000..e55c245fd --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.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. +/*--- +template: default +desc: Reset element (nested object pattern) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...{ x } = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case new file mode 100644 index 000000000..4a7b66f86 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.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. +/*--- +template: default +desc: Rest element (array binding pattern) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...[x], y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case new file mode 100644 index 000000000..b569bb020 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.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. +/*--- +template: default +desc: Rest element (identifier) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...x, y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case new file mode 100644 index 000000000..3540f3dd1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.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. +/*--- +template: default +desc: Rest element (object binding pattern) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...{ x }, y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case new file mode 100644 index 000000000..5270aadda --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.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. +/*--- +template: default +desc: Rest element containing an object binding pattern +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +//- elems +[...{ length }] +//- vals +[1, 2, 3] +//- body +assert.sameValue(length, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case new file mode 100644 index 000000000..17c410b43 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.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. +/*--- +template: default +desc: Rest element containing an object binding pattern +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +//- setup +let length = "outer"; +//- elems +[...{ 0: v, 1: w, 2: x, 3: y, length: z }] +//- vals +[7, 8, 9] +//- body +assert.sameValue(v, 7); +assert.sameValue(w, 8); +assert.sameValue(x, 9); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +assert.sameValue(length, "outer", "the length prop is not set as a binding name"); diff --git a/src/dstr-binding/default/for-await-of-async-func-const-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template index a897bc969..a897bc969 100644 --- a/src/dstr-binding/default/for-await-of-async-func-const-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template diff --git a/src/dstr-binding/default/for-await-of-async-func-const.template b/src/dstr-binding-for-await/default/for-await-of-async-func-const.template index b4a0fffd8..b4a0fffd8 100644 --- a/src/dstr-binding/default/for-await-of-async-func-const.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-const.template diff --git a/src/dstr-binding/default/for-await-of-async-func-let-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template index 6f971f061..6f971f061 100644 --- a/src/dstr-binding/default/for-await-of-async-func-let-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template diff --git a/src/dstr-binding/default/for-await-of-async-func-let.template b/src/dstr-binding-for-await/default/for-await-of-async-func-let.template index c184e3b5f..c184e3b5f 100644 --- a/src/dstr-binding/default/for-await-of-async-func-let.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-let.template diff --git a/src/dstr-binding/default/for-await-of-async-func-var-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template index 168232082..168232082 100644 --- a/src/dstr-binding/default/for-await-of-async-func-var-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template diff --git a/src/dstr-binding/default/for-await-of-async-func-var.template b/src/dstr-binding-for-await/default/for-await-of-async-func-var.template index 2d1e14265..2d1e14265 100644 --- a/src/dstr-binding/default/for-await-of-async-func-var.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-var.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-const-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template index 592433e70..592433e70 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-const-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-const.template index f8627fbd1..f8627fbd1 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-const.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-const.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-let-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template index aeb133ad4..aeb133ad4 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-let-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-let.template index 99a60f8dd..99a60f8dd 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-let.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-let.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-var-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template index c251fda07..c251fda07 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-var-async.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template diff --git a/src/dstr-binding/default/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-var.template index 798f4fa22..798f4fa22 100644 --- a/src/dstr-binding/default/for-await-of-async-gen-var.template +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-var.template diff --git a/src/dstr-binding/error/for-await-of-async-func-const.template b/src/dstr-binding-for-await/error/for-await-of-async-func-const.template index dc2fc2499..046172877 100644 --- a/src/dstr-binding/error/for-await-of-async-func-const.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-const.template @@ -43,6 +43,11 @@ async function fn() { } fn() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-func-let.template b/src/dstr-binding-for-await/error/for-await-of-async-func-let.template index 291b51a64..1a018086d 100644 --- a/src/dstr-binding/error/for-await-of-async-func-let.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-let.template @@ -43,6 +43,11 @@ async function fn() { } fn() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-func-var.template b/src/dstr-binding-for-await/error/for-await-of-async-func-var.template index ab9ae9712..cfc53e285 100644 --- a/src/dstr-binding/error/for-await-of-async-func-var.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-var.template @@ -43,5 +43,10 @@ async function fn() { } fn() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-const.template index 4f4f2deb0..85241ea97 100644 --- a/src/dstr-binding/error/for-await-of-async-gen-const.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-const.template @@ -43,6 +43,10 @@ async function * gen() { } gen().next() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); - diff --git a/src/dstr-binding/error/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-let.template index 38c2f00fb..f75e5e204 100644 --- a/src/dstr-binding/error/for-await-of-async-gen-let.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-let.template @@ -43,5 +43,10 @@ async function * gen() { } gen().next() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-var.template index 41f9d08a2..c0bbe2f0f 100644 --- a/src/dstr-binding/error/for-await-of-async-gen-var.template +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-var.template @@ -43,6 +43,11 @@ async function * gen() { } gen().next() - .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) .then($DONE, $DONE); diff --git a/src/dstr-binding/iter-close/for-await-of-async-func-const.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template index 810e76c3f..810e76c3f 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-func-const.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template diff --git a/src/dstr-binding/iter-close/for-await-of-async-func-let.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template index b58a49e0d..b58a49e0d 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-func-let.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template diff --git a/src/dstr-binding/iter-close/for-await-of-async-func-var.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template index 4f38c2f89..4f38c2f89 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-func-var.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template diff --git a/src/dstr-binding/iter-close/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template index 718187bba..718187bba 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-gen-const.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template diff --git a/src/dstr-binding/iter-close/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template index 020dee9bc..020dee9bc 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-gen-let.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template diff --git a/src/dstr-binding/iter-close/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template index 0d95fda7d..0d95fda7d 100644 --- a/src/dstr-binding/iter-close/for-await-of-async-gen-var.template +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template diff --git a/src/dstr-binding-for-await/obj-init-null.case b/src/dstr-binding-for-await/obj-init-null.case new file mode 100644 index 000000000..23aa54c10 --- /dev/null +++ b/src/dstr-binding-for-await/obj-init-null.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. +/*--- +template: error +desc: Value specifed for object binding pattern must be object coercible (null) +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- elems +{} +//- vals +null +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-init-undefined.case b/src/dstr-binding-for-await/obj-init-undefined.case new file mode 100644 index 000000000..90d27b009 --- /dev/null +++ b/src/dstr-binding-for-await/obj-init-undefined.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. +/*--- +template: error +desc: Value specifed for object binding pattern must be object coercible (undefined) +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- elems +{} +//- vals +undefined +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-empty.case b/src/dstr-binding-for-await/obj-ptrn-empty.case new file mode 100644 index 000000000..1431451d4 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-empty.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. +/*--- +template: default +desc: No property access occurs for an "empty" object binding pattern +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- setup +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); +//- elems +{} +//- vals +obj +//- body +assert.sameValue(accessCount, 0); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case b/src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case new file mode 100644 index 000000000..b2362e7eb --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-get-value-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. +/*--- +template: error +desc: Error thrown when accessing the corresponding property of the value object +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ + +//- setup +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); +//- elems +{ poisoned } +//- vals +poisonedProperty +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case new file mode 100644 index 000000000..998eff71d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.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: SingleNameBinding assigns `name` to arrow functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer 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, + bindingId). +---*/ + +//- elems +{ arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case new file mode 100644 index 000000000..32efdf247 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.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: SingleNameBinding assigns `name` to "anonymous" classes +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer 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, + bindingId). +---*/ + +//- elems +{ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case new file mode 100644 index 000000000..219617289 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.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: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer 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, + bindingId). +---*/ + +//- elems +{ cover = (function () {}), xCover = (0, function() {}) } +//- vals +{} +//- body +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case new file mode 100644 index 000000000..a2a99b438 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.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: SingleNameBinding assigns name to "anonymous" functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer 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, + bindingId). +---*/ + +//- elems +{ fn = function () {}, xFn = function x() {} } +//- vals +{} +//- body +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case new file mode 100644 index 000000000..3eb8bcd5d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.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: SingleNameBinding assigns name to "anonymous" generator functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer 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, + bindingId). +---*/ + +//- elems +{ gen = function* () {}, xGen = function* x() {} } +//- vals +{} +//- body +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case b/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case new file mode 100644 index 000000000..8d666d508 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.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: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +{ w = counter(), x = counter(), y = counter(), z = counter() } +//- vals +{ w: null, x: 0, y: false, z: '' } +//- body +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-throws.case b/src/dstr-binding-for-await/obj-ptrn-id-init-throws.case new file mode 100644 index 000000000..411983d82 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-throws.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. +/*--- +template: error +desc: Error thrown when evaluating the initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ x = thrower() } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case b/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case new file mode 100644 index 000000000..9e00a4aad --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.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: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.1 GetValue ( V ) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +//- elems +{ x = unresolvableReference } +//- vals +{} +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case new file mode 100644 index 000000000..3cfb1f710 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.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. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x, } +//- vals +{ x: 23 } +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/obj-ptrn-list-err.case b/src/dstr-binding-for-await/obj-ptrn-list-err.case new file mode 100644 index 000000000..fd545b398 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-list-err.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. +/*--- +template: error +desc: Binding property list evaluation is interrupted by an abrupt completion +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ + +//- setup +var initCount = 0; +function thrower() { + throw new Test262Error(); +} +//- elems +{ a, b = thrower(), c = ++initCount } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case new file mode 100644 index 000000000..d5cded54a --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.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. +/*--- +template: default +desc: Object binding pattern with "nested" array binding pattern using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{} +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case new file mode 100644 index 000000000..7cccbd084 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.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. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x: [y], } +//- vals +{ x: [45] } +//- body +assert.sameValue(y,45); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case new file mode 100644 index 000000000..af5b3ec08 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.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. +/*--- +template: error +desc: Object binding pattern with "nested" array binding pattern taking the `null` value +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{ w: null } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary.case new file mode 100644 index 000000000..40a73c566 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary.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. +/*--- +template: default +desc: Object binding pattern with "nested" array binding pattern not using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{ w: [7, undefined, ] } +//- body +assert.sameValue(x, 7); +assert.sameValue(y, undefined); +assert.sameValue(z, undefined); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case b/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case new file mode 100644 index 000000000..12e985009 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.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 property name returns an abrupt completion +template: error +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ [thrower()]: x } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case new file mode 100644 index 000000000..5b6c9d14d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-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: Error thrown when accessing the corresponding property of the value object +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ + +//- setup +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); +//- elems +{ poisoned: x = ++initEvalCount } +//- vals +poisonedProperty +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case new file mode 100644 index 000000000..ad6d039b1 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case @@ -0,0 +1,43 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +{ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } +//- vals +{ s: null, u: 0, w: false, y: '' } +//- body +assert.sameValue(t, null); +assert.sameValue(v, 0); +assert.sameValue(x, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); + +assert.throws(ReferenceError, function() { + s; +}); +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case new file mode 100644 index 000000000..07d185806 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.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. +/*--- +template: error +desc: Error thrown when evaluating the initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ x: y = thrower() } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case new file mode 100644 index 000000000..d7192fad3 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.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: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.1 GetValue ( V ) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +//- elems +{ x: y = unresolvableReference } +//- vals +{} +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init.case new file mode 100644 index 000000000..4ec47bb8e --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init.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. +/*--- +template: default +desc: Binding as specified via property name, identifier, and initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +{ x: y = 33 } +//- vals +{ } +//- body +assert.sameValue(y, 33); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case new file mode 100644 index 000000000..c131b3e34 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.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. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x: y, } +//- vals +{ x: 23 } +//- body +assert.sameValue(y, 23); + +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id.case b/src/dstr-binding-for-await/obj-ptrn-prop-id.case new file mode 100644 index 000000000..6ddeaba2b --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id.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. +/*--- +template: default +desc: Binding as specified via property name and identifier +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +{ x: y } +//- vals +{ x: 23 } +//- body +assert.sameValue(y, 23); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case new file mode 100644 index 000000000..6132854fb --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.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. +/*--- +template: default +desc: Object binding pattern with "nested" object binding pattern using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: undefined } +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case new file mode 100644 index 000000000..2ea5ba4d0 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.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. +/*--- +template: error +desc: Object binding pattern with "nested" object binding pattern taking the `null` value +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: null } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case new file mode 100644 index 000000000..a19912f83 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.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. +/*--- +template: error +desc: Object binding pattern with "nested" object binding pattern taking the `null` value +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: { x, y, z } = undefined } +//- vals +{ } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj.case new file mode 100644 index 000000000..c38a0b8a2 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj.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. +/*--- +template: default +desc: Object binding pattern with "nested" object binding pattern not using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: { x: undefined, z: 7 } } +//- body +assert.sameValue(x, undefined); +assert.sameValue(y, undefined); +assert.sameValue(z, 7); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-getter.case b/src/dstr-binding-for-await/obj-ptrn-rest-getter.case new file mode 100644 index 000000000..c5360e5e5 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-getter.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Caio Lima. 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 +var 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"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case b/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case new file mode 100644 index 000000000..8fb0bb2d1 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. 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 +var obj = {a: 3, b: 4}; +//- 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); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case b/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case new file mode 100644 index 000000000..a6eb8c024 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. 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] +---*/ + +//- 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"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case b/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case new file mode 100644 index 000000000..71c375adc --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just soruce object's own properties +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; +//- elems +{ x, ...{y , z} } +//- vals +o +//- body +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case b/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case new file mode 100644 index 000000000..869ffd241 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Caio Lima. 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 +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); +//- elems +{...rest} +//- vals +o +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(rest.x, undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case b/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case new file mode 100644 index 000000000..0379ddd94 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima. 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] +---*/ + +//- 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"); + |