diff --git a/src/dstr-assignment-async-iteration/array-elem-init-assignment.case b/src/dstr-assignment-async-iteration/array-elem-init-assignment.case index 4a736a739581ae3cbfaf00f7d1ed8746e39aa8bd..d6e17a22f549e93616d542506b569115b2c413ec 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-assignment.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-assignment.case @@ -9,7 +9,7 @@ template: default ---*/ //- setup -var v2, vNull, vHole, vUndefined, vOob; +let v2, vNull, vHole, vUndefined, vOob; //- elems [v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case b/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case index b3b767fa1c7dfdbfe943d21378796076a25adb55..85ec19f4affb747a0001a66493f9f3cf893d9bda 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-evaluation.case @@ -8,8 +8,8 @@ template: default ---*/ //- setup -var flag1 = false, flag2 = false; -var _; +let flag1 = false, flag2 = false; +let _; //- elems [ _ = flag1 = true, _ = flag2 = true ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case index e95a3117c9d4e97f30bb96b3365d4ddbf43cfd87..d3cf8df244f96a63c13f4f72eea848a60cd5a270 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow.case @@ -11,15 +11,13 @@ info: > 7. If Initializer is present and value is undefined and IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then - a. Let hasNameProperty be HasOwnProperty(v, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, perform SetFunctionName(v, - GetReferencedName(lref)). + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). includes: [propertyHelper.js] ---*/ //- setup -var arrow; +let arrow; //- elems [ arrow = () => {} ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case index 2849395c5f02e838e46a7c37445b8834219a0d58..448124558ad45f47710256eaf4e2f18929fa7c8e 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-class.case @@ -11,16 +11,14 @@ info: > 7. If Initializer is present and value is undefined and IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then - a. Let hasNameProperty be HasOwnProperty(v, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, perform SetFunctionName(v, - GetReferencedName(lref)). + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). includes: [propertyHelper.js] features: [class] ---*/ //- setup -var xCls, cls, xCls2; +let xCls, cls, xCls2; //- elems [ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case index 093eea2614a113e41e6f307d78b158a60db05cf1..348a1ced776b6743164c6330056ff2fd25851856 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -12,15 +12,13 @@ info: > 7. If Initializer is present and value is undefined and IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then - a. Let hasNameProperty be HasOwnProperty(v, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, perform SetFunctionName(v, - GetReferencedName(lref)). + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). includes: [propertyHelper.js] ---*/ //- setup -var xCover, cover; +let xCover, cover; //- elems [ xCover = (0, function() {}), cover = (function() {}) ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case index d2e65e618f99ba0c24e75a47dac648dd464ae95a..d6d2d5702ddef88631e3f434e7685c2b4bd219be 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,27 +11,25 @@ info: > 7. If Initializer is present and value is undefined and IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then - a. Let hasNameProperty be HasOwnProperty(v, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, perform SetFunctionName(v, - GetReferencedName(lref)). + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). includes: [propertyHelper.js] features: [class] ---*/ //- setup -var xFn, fn; +let xFnexp, fnexp; //- elems -[ xFn = function x() {}, fn = function() {} ] +[ xFnexp = function x() {}, fnexp = function() {} ] //- vals [] //- body -assert(xFn.name !== 'xFn'); +assert(xFnexp.name !== 'xFnexp'); -assert.sameValue(fn.name, 'fn'); -verifyNotEnumerable(fn, 'name'); -verifyNotWritable(fn, 'name'); -verifyConfigurable(fn, 'name'); +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); //- teardown promise diff --git a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case index 137f38423bad28c81e0cbeffd25ab954f1fd3586..c05ff848f59a7e79e30006e89d87f096889cb9bf 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case @@ -11,16 +11,14 @@ info: > 7. If Initializer is present and value is undefined and IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then - a. Let hasNameProperty be HasOwnProperty(v, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, perform SetFunctionName(v, - GetReferencedName(lref)). + a. Let hasNameProperty be ? HasOwnProperty(v, "name"). + b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)). includes: [propertyHelper.js] features: [generators] ---*/ //- setup -var xGen, gen; +let xGen, gen; //- elems [ xGen = function* x() {}, gen = function*() {} ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-in.case b/src/dstr-assignment-async-iteration/array-elem-init-in.case index be7e9345d89121b681006f8553165906072f5e85..70435eba4fef3a841d4c391b5e7b5c0224a1dffe 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-in.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-in.case @@ -8,7 +8,7 @@ template: default ---*/ //- setup -var x; +let x; //- elems [ x = 'x' in {} ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-let.case b/src/dstr-assignment-async-iteration/array-elem-init-let.case new file mode 100644 index 0000000000000000000000000000000000000000..b25e02e031b1eabb81bb8e8231890b7156ca82a8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-let.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Value retrieval of Initializer obeys `let` semantics. +template: default +es6id: 12.14.5.3 +features: [let] +---*/ + +//- setup +let x; +//- elems +[ x = y ] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); + +let y; + diff --git a/src/dstr-assignment-async-iteration/array-elem-init-order.case b/src/dstr-assignment-async-iteration/array-elem-init-order.case index c7a11046491c4605b53ff5cdf2bb10fcb9adfdb8..a11457512627cc3e13d180bc1bcd1364e818c399 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-order.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-order.case @@ -8,8 +8,8 @@ template: default ---*/ //- setup -var x = 0; -var a, b; +let x = 0; +let a, b; //- elems [ a = x += 1, b = x *= 2 ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case b/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case index 55fd0297eb4a7485351e21cd18a18521a812cdbe..c5e33b30396e6e33277199f49313637a6b24cf47 100644 --- a/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case +++ b/src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case @@ -11,7 +11,7 @@ flags: [noStrict] ---*/ //- setup -var argument, eval; +let argument, eval; //- elems [arguments = 4, eval = 5] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..0d3cdfd55a33651ff53f045ee28798ade2643c57 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentElement within a generator function body, it behaves as a + YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let value = []; +let x; +//- elems +[ x = yield ] +//- vals +[] +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 4); + }, $DONE).then($DONE, $DONE); +}, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..559a52fc22cc403eb7293e58ece57f44402e10e7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-invalid.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + outside of a generator function body, it behaves as an IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.4 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[ x = yield ] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..01b1ed2a1f675f293f5cf33f6f8363e416e7ad81 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-init-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + outside of a generator function body, it behaves as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 4; +let x; +//- elems +[ x = yield ] +//- vals +[] +//- body +assert.sameValue(x, 4); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case b/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case new file mode 100644 index 0000000000000000000000000000000000000000..06ebf52f86c409ed5758c1a4504a5a2f21433b6b --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-get-err.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from GetIterator +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + 1. Let iterator be ? GetIterator(value). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterable = { + [Symbol.iterator]() { + throw new Test262Error(); + } +}; +let _; + +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..3ca0ccc29dc84574531ad7d5c85c9e0eff99f4c8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-err.case @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let _; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..d03a318ae0b99d782ad9be5c89d628b4911e4acb --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-null.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[Type]] is throw, return Completion(completion). + 7. If innerResult.[[Type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let _; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ _ ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case index 322e4f2f5aa118a3efa025bea0b07415b33cfddf..9391d14623cb873efbf54e01afa6830132bc2cba 100644 --- a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case @@ -8,30 +8,31 @@ info: | ArrayAssignmentPattern : [ AssignmentElementList ] [...] - 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). - 6. Return result. + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. features: [Symbol.iterator] -template: default +template: async-generator esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var _; -var iterable = {}; -var iterator = { - next: function() { +let nextCount = 0; +let returnCount = 0; +let _; +let iterator = { + next() { nextCount += 1; return { done: true }; }, - return: function() { + return() { returnCount += 1; return {}; } }; -iterable[Symbol.iterator] = function() { - return iterator; +let iterable = { + [Symbol.iterator]() { + return iterator; + } }; //- elems [ _ ] @@ -42,6 +43,6 @@ assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); //- teardown -promise - .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) - .then($DONE, $DONE); +iter.next().then(() => { + assert.sameValue(iterCount, 1); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case index 70a33b9705d014b054d11377ebea0704e4f31e58..55aa045efbf9f6700b30ad02e2b14d16dd5d3b76 100644 --- a/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case +++ b/src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case @@ -8,14 +8,13 @@ info: | ArrayAssignmentPattern : [ AssignmentElementList ] [...] - 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, - result). - 6. Return result. + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. - 7.4.6 IteratorClose( iterator, completion ) + 7.4.6 IteratorClose ( iterator, completion ) [...] - 6. Let innerResult be Call(return, iterator, « »). + 5. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] template: default @@ -23,20 +22,20 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thisValue = null; -var args = null; -var _; -var iterable = {}; -var iterator = { - next: function() { +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: function() { + return() { returnCount += 1; thisValue = this; args = arguments; diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..ff7953160a69bb844f2b49b7a8fc472f32637ce8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-rtrn-close-null.case @@ -0,0 +1,49 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[Type]] is throw, return Completion(completion). + 7. If innerResult.[[Type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let unreachable = 0; +let iterator = { + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ {}[yield] ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(unreachable, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..71d03881c431d0a6e275763b1a4c364e74378862 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-iter-thrw-close-skip.case @@ -0,0 +1,46 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when iteration produces an abrupt completion +info: | + ArrayAssignmentPattern : [ AssignmentElementList ] + + [...] + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result). + 5. Return result. +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterator = { + next() { + nextCount += 1; + throw new Test262Error(); + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +let _; + +//- elems +[ x ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 0); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..c61cdc9a8282856cc399793196fddea85af1d1ab --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +template: error-async-function-syntax +es6id: 12.14.5.1 +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[[(x, y)]] +//- vals +[[]] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case new file mode 100644 index 0000000000000000000000000000000000000000..7d2d69ddbd9ed3a0013227001101c5ddb5a4d774 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-null.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is + `null`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ _ ]] +//- vals +[null] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..cee7a05585d79e697ea22f8adebad5f4f1798d4d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-hole.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is a + "hole", a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ _ ]] +//- vals +[ , ] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..0b19e67885f82c026114ae30925ae16ad743a0e6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined-own.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and the value is + `undefined`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; + +//- elems +[[ x ]] +//- vals +[undefined] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..cba070d9369650c64984d4abd820bdd6c9b9be64 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-undefined.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal and no value is + defined, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let _; +//- elems +[[ x ]] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..1d322f0d253ef5c2c3be1313a5c2411e8b852cef --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-expr.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment and within a generator function body, it + behaves as a YieldExpression. +template: async-generator +es6id: 12.14.5.3 +features: [generators] +---*/ + +//- setup +let value = [[22]]; +let x = {}; + +//- elems +[[x[yield]]] +//- vals +value +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x.prop, 22); + }, $DONE).then($DONE, $DONE); +}, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..bf7e26e6c3d725382075bd18019605979237665d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of a + nested destructuring assignment outside of strict mode, it behaves as an + IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.3 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[[x[yield]]] +//- vals +[[]] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case index cd2b0313b1ed17f0d1c828c23e68884bb5f05e40..6ec543b1656b6d53481e1c8c6c83826285fab9d3 100644 --- a/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case @@ -6,16 +6,20 @@ desc: > When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. -template: default +template: async-function flags: [noStrict] ---*/ //- setup -var yield = 'prop'; -var x = {}; +let yield = 'prop'; +let x = {}; //- elems [[x[yield]]] //- vals [[22]] //- body assert.sameValue(x.prop, 22); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-array.case b/src/dstr-assignment-async-iteration/array-elem-nested-array.case index f5cbc1ff8ac0ca7b7be7478d5a8bbf8a9f937484..7ccce4947f40a2b1ba442bfafd328cced36f502c 100644 --- a/src/dstr-assignment-async-iteration/array-elem-nested-array.case +++ b/src/dstr-assignment-async-iteration/array-elem-nested-array.case @@ -6,14 +6,18 @@ desc: > When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. -template: default +template: async-function ---*/ //- setup -var x; +let x; //- elems [[x]] //- vals [[1]] //- body assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..c4b38e413d43fe9cf49be174e44567686cc8b2b5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +template: error-async-function-syntax +es6id: 12.14.5.1 +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[{ get x() {} }] +//- vals +[{}] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case new file mode 100644 index 0000000000000000000000000000000000000000..24025d5cf64003171134fef6319acb907a7052d6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-null.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is + `null`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x; +//- elems +[{ x }] +//- vals +[null] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case new file mode 100644 index 0000000000000000000000000000000000000000..9dd7c5eb495b0ddf0fc5ef9f0e9f71aca01135a8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-hole.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is a + "hole", a TypeError should be thrown. +template: default +es6id: 12.14.5.3 + +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[ , ] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case new file mode 100644 index 0000000000000000000000000000000000000000..7b2a81724226ad2f2052038cd0ff1f864a9f4693 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined-own.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and the value is + `undefined`, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 + +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[undefined] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case new file mode 100644 index 0000000000000000000000000000000000000000..19b426f710bb6068adeb1ff46723a479ebc3714d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-undefined.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal and no value is + defined, a TypeError should be thrown. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x; + +//- elems +[{ x }] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case index 84af24b9a51036fde3936330ae3bccf15ac41b94..8d1e3e58583cf86a019751198342eaea956d015c 100644 --- a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case @@ -10,7 +10,7 @@ template: async-generator ---*/ //- setup -var x; +let x; //- elems @@ -18,14 +18,14 @@ var x; //- vals [{}] //- teardown -iter.next().then(iterationResult => { - assert.sameValue(iterationResult.value, undefined); - assert.sameValue(iterationResult.done, false); +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); assert.sameValue(x, undefined); - iter.next(4).then(iterationResult => { - assert.sameValue(iterationResult.value, undefined); - assert.sameValue(iterationResult.done, true); + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); assert.sameValue(x, 4); }, $DONE).then($DONE, $DONE); }, $DONE).catch($DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..6edca7faf60cc9c3234fda90548b729556a1aeed --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment outside of a generator function body, it behaves + as a IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.3 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[{ x = yield }] +//- vals +[{}] diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case index 09b4eff6141ebd08fff3591af5b4a40398274696..be16ef13ad28fc37d24a5c8370755b0da7cc2606 100644 --- a/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid.case @@ -11,8 +11,8 @@ flags: [noStrict] ---*/ //- setup -var yield = 2; -var x; +let yield = 2; +let x; //- elems [{ x = yield }] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-nested-obj.case b/src/dstr-assignment-async-iteration/array-elem-nested-obj.case index 50faa760f9e91790b65e597ba9ac3485a7712088..41f922d2bdf5d9de38bd21cbdb355ffbbd13f0b5 100644 --- a/src/dstr-assignment-async-iteration/array-elem-nested-obj.case +++ b/src/dstr-assignment-async-iteration/array-elem-nested-obj.case @@ -10,7 +10,7 @@ template: default ---*/ //- setup -var x; +let x; //- elems [{ x }] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-put-const.case b/src/dstr-assignment-async-iteration/array-elem-put-const.case new file mode 100644 index 0000000000000000000000000000000000000000..60709de651fc4ce18bc40bd8817f5194ac3e8707 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-const.case @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The assignment target should obey `const` semantics. +template: default +es6id: 12.14.5.3 +features: [const] +---*/ + +//- setup +const c = null; +//- elems +[ c ] +//- vals +[1] diff --git a/src/dstr-assignment-async-iteration/array-elem-put-let.case b/src/dstr-assignment-async-iteration/array-elem-put-let.case new file mode 100644 index 0000000000000000000000000000000000000000..69a58f42813d25991ecb8f7e0f12e658526bd065 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-let.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The assignment target should obey `let` semantics. +template: default +es6id: 12.14.5.3 +features: [let] +---*/ + +//- elems +[ x ] +//- vals +[] +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); + +let x; diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case index 217eff2dba2f4f1280a4e8e3bb6bfeda72fe0d18..67fde98843b539491554c886de343c944aa6fcfc 100644 --- a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get.case @@ -9,7 +9,7 @@ template: default ---*/ //- setup -var x, setValue; +let x, setValue; x = { get y() { $ERROR('The property should not be accessed.'); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case new file mode 100644 index 0000000000000000000000000000000000000000..fdba045b9b2df28190446c2a270d2f619234a3d0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref-user-err.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Any error raised as a result of setting the value should be forwarded to + the runtime. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +let x = { + set y(val) { + throw new Test262Error(); + } +}; +//- elems +[x.y] +//- vals +[23] + +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case index 111e769e7dab735f58ff3cb2aad2b5c5ccc4cc2f..9d18ee63c52d64a789833af9c276e667d398f547 100644 --- a/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case +++ b/src/dstr-assignment-async-iteration/array-elem-put-prop-ref.case @@ -9,7 +9,7 @@ template: default ---*/ //- setup -var x = {}; +let x = {}; //- elems [x.y] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..33b0acc19e71dd72b32da6da2450a6dfa7335773 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-put-unresolvable-strict.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + In strict mode, if the the assignment target is an unresolvable reference, + a ReferenceError should be thrown. +template: default +es6id: 12.14.5.3 +flags: [onlyStrict] +---*/ + +//- elems +[ unresolvable ] +//- vals +[] + +//- teardown +promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, ReferenceError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-identifier.case b/src/dstr-assignment-async-iteration/array-elem-target-identifier.case index 466742c255b6b643205e9c3fac5d6fcd01d4af60..07d21bbb6e87be7040da5dd838aee6df2b0d66cf 100644 --- a/src/dstr-assignment-async-iteration/array-elem-target-identifier.case +++ b/src/dstr-assignment-async-iteration/array-elem-target-identifier.case @@ -10,7 +10,7 @@ template: async-function ---*/ //- setup -var x, y, z; +let x, y, z; //- elems [x, y, z] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case b/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case index e626f3be26e1e407c1413736b7ad5299eef00b73..0f9f8ed3c537fb57f29ac0ca87dd4995f49c9b3b 100644 --- a/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case +++ b/src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case @@ -11,7 +11,7 @@ flags: [noStrict] ---*/ //- setup -var argument, eval; +let argument, eval; //- elems [arguments, eval] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case b/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..a68cc95cb2a95bedd546421042fdae4c608d9b2a --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-simple-strict.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a Syntax Error if LeftHandSideExpression is neither an + ObjectLiteral nor an ArrayLiteral and + IsValidSimpleAssignmentTarget(LeftHandSideExpression) is + false. +template: error-async-function-syntax +es6id: 12.14.5.1 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[arguments] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case index 51d841a826af7e93eb1e8bdd133052772afefb7d..0f796b4ea87b2aecebb875da5864bf9f8f8ec2a6 100644 --- a/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case @@ -11,9 +11,9 @@ features: [generators] ---*/ //- setup -var value = [33]; -var x = {}; -var iterationResult; +let value = [33]; +let x = {}; +let iterationResult; //- elems [ x[yield] ] @@ -27,8 +27,6 @@ iter.next().then(iterationResult => { assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); - // TODO add iterCount - // iter.next('prop').then(iterationResult => { assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..d22bab44e17f1582049b244365f2a3fe5ab3c332 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and outside of a generator function body, it behaves as + an IdentifierReference. +template: error-async-function-syntax +es6id: 12.14.5.4 +flags: [onlyStrict] +negative: + phase: early + type: SyntaxError +---*/ + +//- elems +[ x[yield] ] +//- vals +[] diff --git a/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case b/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case index 5e947aab32814073615fb1c1d0540710dc77e7a2..47f18669655a6ba5fcbb9a5e87226a3b6790ac8a 100644 --- a/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case +++ b/src/dstr-assignment-async-iteration/array-elem-target-yield-valid.case @@ -11,8 +11,8 @@ flags: [noStrict] ---*/ //- setup -var yield = 'prop'; -var x = {}; +let yield = 'prop'; +let x = {}; //- elems [ x[yield] ] //- vals diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case new file mode 100644 index 0000000000000000000000000000000000000000..29f053d1a5d36360637cb0f5ff8a1cafd99b4bfe --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-abpt.case @@ -0,0 +1,63 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned during evaluation of elision +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + i. If iteratorRecord.[[done]] is false, return + IteratorClose(iterator, status). + ii. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + + if (nextCount === 2) { + throw new Test262Error(); + } + + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , , ] +//- vals +iterable +//- teardown + +iter.next().then(() => { + iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 2); + assert.sameValue(returnCount, 0); + assert.sameValue(constructor, Test262Error); + + }).then($DONE, $DONE); +}, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..96dd11cabe853106d9f2467e1bfc2254595a5ce1 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-err.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + [...] + 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(nextCount, 2); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + + + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..5b831a9de408bf6ad899a3cc5a4c4931b1855cc1 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-null.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. If status is an abrupt completion, then + [...] + 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 6. Let innerResult be Call(return, iterator, « »). + 7. If completion.[[type]] is throw, return Completion(completion). + 8. If innerResult.[[type]] is throw, return Completion(innerResult). + 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. +features: [Symbol.iterator] +template: default +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let x; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- error +TypeError +//- elems +[ x , , ] +//- vals +iterable diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case index 5f2a03b450ee0982d7c2a21b07e826cd59a9c911..835a6ad7da9f2e8b9f81bc9a331d52141a04501a 100644 --- a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close-skip.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// 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 @@ -7,13 +7,15 @@ info: | [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [...] - 6. If Elision is present, then + 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 - [...] - 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + + [...] + + 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, status). 9. Return Completion(status). features: [Symbol.iterator] @@ -22,10 +24,10 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var x; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { next() { nextCount += 1; @@ -35,7 +37,7 @@ var iterator = { returnCount += 1; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case index 57df4273cfef89f522110427d289b1196c5ddb2d..0ae8bcccafe8e4281e637ae308739a81975e7d8c 100644 --- a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-elision-iter-nrml-close.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// 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 @@ -7,19 +7,21 @@ info: | [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [...] - 6. If Elision is present, then + 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 - [...] - 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + + [...] + + 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, status). - 7.4.6 IteratorClose( iterator, completion ) + 7.4.6 IteratorClose ( iterator, completion ) [...] - 6. Let innerResult be Call(return, iterator, « »). + 5. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] template: async-generator @@ -27,12 +29,12 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thisValue = null; -var args = null; -var x; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let x; +let iterator = { next() { nextCount += 1; @@ -47,7 +49,7 @@ var iterator = { return {}; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case new file mode 100644 index 0000000000000000000000000000000000000000..5fcb2eacb5ea9268382aefc8689f23ac0a80351d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-get-err.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from GetIterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterable = { + [Symbol.iterator]() { + throw new Test262Error(); + } +}; +let x; +//- elems +[ x , ] +//- vals +iterable + +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..fe44dc0900e76d4de47b3b311648ff4331bd7db6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-err.case @@ -0,0 +1,59 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned from IteratorClose +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let thrower = function() { + throw new Test262Error(); +}; +let x; +let iterator = { + next() { + nextCount += 1; + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..8669d0013c69e07c232dce081f1bbc6c71d44175 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-null.case @@ -0,0 +1,65 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let x; +let nextCount = 0; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- error +TypeError +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case index 6f94122f00c531a6defc439ec32b5c6fefda3778..d1828dc29cace18444cd44d9018a7b064092e0d8 100644 --- a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close-skip.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > @@ -9,11 +9,11 @@ info: | [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [...] - 3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. - 4. Let status be the result of performing + 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. - 5. If status is an abrupt completion, then + 4. If status is an abrupt completion, then a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, status). b. Return Completion(status). @@ -23,13 +23,13 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thrower = function() { +let nextCount = 0; +let returnCount = 0; +let thrower = function() { throw new Test262Error(); }; -var x; -var iterator = { +let x; +let iterator = { next() { nextCount += 1; return { done: true }; @@ -38,7 +38,7 @@ var iterator = { returnCount += 1; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case index 792e09097adfdf8a29e4478ac14ad7ef1efaa352..04f371d5acbba66dddc87fc43c9778dac6f6e93e 100644 --- a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-nrml-close.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > @@ -9,19 +9,19 @@ info: | [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [...] - 3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. - 4. Let status be the result of performing + 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. - 5. If status is an abrupt completion, then + 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 ) + 7.4.6 IteratorClose ( iterator, completion ) [...] - 6. Let innerResult be Call(return, iterator, « »). + 5. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] template: async-generator @@ -29,12 +29,12 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thisValue = null; -var args = null; -var x; -var iterator = { +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 @@ -48,7 +48,7 @@ var iterator = { return {}; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..284200130270f9ab60b4911ad758d8c6513e7ae2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-err.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is invoked when evaluation of AssignmentElementList returns + a "return" completion and the iterator has not been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let returnCount = 0; +let unreachable = 0; +let iterator = { + return() { + returnCount += 1; + + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(returnCount, 1); + assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..7b8971233e23bd52e8c51636281fa69ab9ed5e50 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close-null.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + 8. If Type(innerResult.[[value]]) is not Object, throw a TypeError + exception. + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let iterator = { + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + + +//- elems + [ {}[yield] , ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, TypeError); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case new file mode 100644 index 0000000000000000000000000000000000000000..bb04127070d7171ffa4e1b4d5f97a9ac52becc2d --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-rtrn-close.case @@ -0,0 +1,68 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is invoked when evaluation of AssignmentElementList returns + a "return" completion and the iterator has not been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}. + 3. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 4. If status is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + b. Return Completion(status). + + 7.4.6 IteratorClose( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let returnCount = 0; +let unreachable = 0; +let thisValue = null; +let args = null; +let iterator = { + return() { + returnCount += 1; + thisValue = this; + args = arguments; + return {}; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + + +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body + unreachable += 1; +//- teardown +iter.return(888).then(result => { + assert.sameValue(returnCount, 1); + assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); + assert.sameValue(result.value, 888); + assert(result.done, 'Iterator correctly closed'); + assert.sameValue(thisValue, iterator, 'correct `this` value'); + assert(!!args, 'arguments object provided'); + assert.sameValue(args.length, 0, 'zero arguments specified'); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..c01dd08a5aa0542932e5c498f1bce0b945bf4fef --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-list-thrw-close-skip.case @@ -0,0 +1,58 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not invoked when evaluation of AssignmentElementList + returns an abrupt completion and the iterator has been marked as "done" +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. + 4. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentElementList using + iteratorRecord as the argument. + 5. If status is an abrupt completion, then + a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, + status). + b. Return Completion(status). +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let iterable = {}; +let thrower = function() { + throw new Test262Error(); +}; +let iterator = { + next() { + nextCount += 1; + throw new Test262Error(); + }, + return() { + returnCount += 1; + } +}; +iterable[Symbol.iterator] = function() { + return iterator; +}; +let x; +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown +iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 0); + assert.sameValue(iterCount, 0); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case new file mode 100644 index 0000000000000000000000000000000000000000..892f618f8bab499279f98727ab195b03b9401f70 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-nrml-close-skip.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is not called when rest element evaluation has exhausted the + iterator +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + +features: [Symbol.iterator] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let x, y; +let iterator = { + next() { + nextCount += 1; + return { value: nextCount, done: nextCount > 1 }; + }, + return() { + returnCount += 1; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; +//- elems +[ x , ...y ] +//- vals +iterable +//- teardown +iter.next().then(() => { + iter.return().then(() => { + assert.sameValue(nextCount, 2, 'nextCount'); + assert.sameValue(returnCount, 0, 'returnCount'); + assert.sameValue(x, 1, 'x'); + assert.sameValue(y.length, 0, 'y.length'); + }).then($DONE, $DONE); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case new file mode 100644 index 0000000000000000000000000000000000000000..c283de7cbfbd4b958e01c24d20e4d2025c296d96 --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-err.case @@ -0,0 +1,69 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose is called when AssignmentRestEvaluation produces a "return" + completion due to reference evaluation +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let returnCount = 0; +let unreachable = 0; +let x; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + returnCount += 1; + + throw new Test262Error(); + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- body + unreachable += 1; +//- teardown +iter.next().then(() => { + iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(returnCount, 1); + assert.sameValue(constructor, Test262Error); + }).then($DONE, $DONE); +}).then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case new file mode 100644 index 0000000000000000000000000000000000000000..69681bac100da0fbb930dba8fa5ea89100ae2d9c --- /dev/null +++ b/src/dstr-assignment-async-iteration/array-elem-trlg-iter-rest-rtrn-close-null.case @@ -0,0 +1,60 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + IteratorClose throws a TypeError when `return` returns a non-Object value +info: | + ArrayAssignmentPattern : + [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] + + [...] + 6. If AssignmentRestElement is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of AssignmentRestElement + with iteratorRecord as the argument. + 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status). + 8. Return Completion(status). + + 7.4.6 IteratorClose ( iterator, completion ) + + [...] + 5. Let innerResult be Call(return, iterator, « »). + 6. If completion.[[type]] is throw, return Completion(completion). + 7. If innerResult.[[type]] is throw, return Completion(innerResult). + +features: [Symbol.iterator, generators] +template: async-generator +es6id: 12.14.5.2 +esid: sec-runtime-semantics-destructuringassignmentevaluation +---*/ + +//- setup +let nextCount = 0; +let x; +let iterator = { + next() { + nextCount += 1; + // Set an upper-bound to limit unnecessary iteration in non-conformant + // implementations + return { done: nextCount > 10 }; + }, + return() { + return null; + } +}; +let iterable = { + [Symbol.iterator]() { + return iterator; + } +}; + +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- teardown +iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => { + assert.sameValue(nextCount, 1); + assert.sameValue(constructor, Test262Error); +}).then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case index 43a0ee8a03ecffe9ec765d0080ccde65eb522837..7edf63e32f873572b5957326e07a0cf91b137726 100644 --- a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case +++ b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close-skip.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > @@ -6,10 +6,11 @@ desc: > info: | ArrayAssignmentPattern : [ Elision ] - 1. Let iterator be GetIterator(value). + 1. Let iterator be ? GetIterator(value). + [...] - 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, - result). + + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).. [...] features: [Symbol.iterator] template: async-generator @@ -17,9 +18,9 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let iterator = { next() { nextCount += 1; return { done: true }; @@ -29,7 +30,7 @@ var iterator = { return {}; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case index 5ec6cbbfd03b04f0094c1f95fdc92ad0e2188507..b4093905f45731aa1c311be9afb79588e9792f10 100644 --- a/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case +++ b/src/dstr-assignment-async-iteration/array-elision-iter-nrml-close.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > @@ -7,16 +7,17 @@ desc: > info: | ArrayAssignmentPattern : [ Elision ] - 1. Let iterator be GetIterator(value). + 1. Let iterator be ? GetIterator(value). + [...] - 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, - result). + + 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).. [...] - 7.4.6 IteratorClose( iterator, completion ) + 7.4.6 IteratorClose ( iterator, completion ) [...] - 6. Let innerResult be Call(return, iterator, « »). + 5. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] template: async-generator @@ -24,11 +25,11 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thisValue = null; -var args = null; -var iterator = { +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 @@ -42,7 +43,7 @@ var iterator = { return {}; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-elision-val-array.case b/src/dstr-assignment-async-iteration/array-elision-val-array.case index 5502f2987802ee81dda470027a234136cc99ceb9..24817be114adb5c2d5d8c3b1901af7b5dd6da1e2 100644 --- a/src/dstr-assignment-async-iteration/array-elision-val-array.case +++ b/src/dstr-assignment-async-iteration/array-elision-val-array.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > diff --git a/src/dstr-assignment-async-iteration/array-elision-val-string.case b/src/dstr-assignment-async-iteration/array-elision-val-string.case index 4c6f1083a00b4d9f70d6304153a74aaa7c37f693..c7dba9e14728eb2a32f8473618cc7e327d3ea696 100644 --- a/src/dstr-assignment-async-iteration/array-elision-val-string.case +++ b/src/dstr-assignment-async-iteration/array-elision-val-string.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > diff --git a/src/dstr-assignment-async-iteration/array-empty-iter-close.case b/src/dstr-assignment-async-iteration/array-empty-iter-close.case index 95222bd089279f3c62e05a37f13a3af82a424eb9..36136e5813e2dbc1f611678dd007ca4ace89e456 100644 --- a/src/dstr-assignment-async-iteration/array-empty-iter-close.case +++ b/src/dstr-assignment-async-iteration/array-empty-iter-close.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// 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 @@ -9,10 +9,10 @@ info: | 2. ReturnIfAbrupt(iterator). 3. Return IteratorClose(iterator, NormalCompletion(empty)). - 7.4.6 IteratorClose( iterator, completion ) + 7.4.6 IteratorClose ( iterator, completion ) [...] - 6. Let innerResult be Call(return, iterator, « »). + 5. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] template: async-generator @@ -20,11 +20,11 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var thisValue = null; -var args = null; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let thisValue = null; +let args = null; +let iterator = { next() { nextCount += 1; return { done: true }; @@ -36,7 +36,7 @@ var iterator = { return {}; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } diff --git a/src/dstr-assignment-async-iteration/array-empty-val-array.case b/src/dstr-assignment-async-iteration/array-empty-val-array.case index 8961f02b65c528527128640e07dc42d3376191bb..7f9aaf7643719f0145c150cc610afd3fcb53defa 100644 --- a/src/dstr-assignment-async-iteration/array-empty-val-array.case +++ b/src/dstr-assignment-async-iteration/array-empty-val-array.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/src/dstr-assignment-async-iteration/array-empty-val-string.case b/src/dstr-assignment-async-iteration/array-empty-val-string.case index 5f395686bdd4335f9952f1c7b20e226f7f46ecc5..6d6d18a3c39c263b1aae4a89f7137c7ff9fbf496 100644 --- a/src/dstr-assignment-async-iteration/array-empty-val-string.case +++ b/src/dstr-assignment-async-iteration/array-empty-val-string.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/src/dstr-assignment-async-iteration/array-rest-after-element.case b/src/dstr-assignment-async-iteration/array-rest-after-element.case index adb195276c933d43073a28670abca507f79fd2c1..df52c96847ddbcea5882beb4f3496792c80a9940 100644 --- a/src/dstr-assignment-async-iteration/array-rest-after-element.case +++ b/src/dstr-assignment-async-iteration/array-rest-after-element.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -10,7 +10,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x, y; +let x, y; //- elems [x, ...y] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-after-elision.case b/src/dstr-assignment-async-iteration/array-rest-after-elision.case index de37221eca0b9d39599ecdf2b7195f0676b90ae2..5dd350dd41e49e9fa34a9da13768993d8fe6ab40 100644 --- a/src/dstr-assignment-async-iteration/array-rest-after-elision.case +++ b/src/dstr-assignment-async-iteration/array-rest-after-elision.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -9,7 +9,7 @@ template: default ---*/ //- setup -var x; +let x; //- elems [, ...x] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-elision.case b/src/dstr-assignment-async-iteration/array-rest-elision.case index f505175c1dd25ccc48f9e01e2bd89564f21a340e..17f9c868c8c5487ef51fb51df9d716d77e23642c 100644 --- a/src/dstr-assignment-async-iteration/array-rest-elision.case +++ b/src/dstr-assignment-async-iteration/array-rest-elision.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -9,7 +9,7 @@ template: default ---*/ //- setup -var x, y; +let x, y; //- elems [, , x, , ...y] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case b/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case index 621cb760195a86fa2da563648beb7a04a0c52f69..297d7d4f78cb06252a376584d4dee8ea675cc671 100644 --- a/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case +++ b/src/dstr-assignment-async-iteration/array-rest-iter-nrml-close-skip.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- desc: > @@ -8,22 +8,21 @@ info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] [...] - 5. Let result be the result of performing - IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with - iteratorRecord as the argument - 6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, - result). - 7. Return result. + 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 -var nextCount = 0; -var returnCount = 0; -var x; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let x; +let iterator = { next() { nextCount += 1; return { done: true }; @@ -32,7 +31,7 @@ var iterator = { returnCount += 1; } }; -var iterable = { +let iterable = { [Symbol.iterator]() { return iterator; } @@ -45,10 +44,7 @@ iterable assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); - -iter.next().then(() => { - assert.throws(Test262Error, () => iter.return()); - assert.sameValue(returnCount, 1); - assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); -}) - +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-err.case b/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-err.case deleted file mode 100644 index e7395c69c5b309de9a7febdcd9a6ffcff1873973..0000000000000000000000000000000000000000 --- a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-err.case +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2016 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 reference evaluation produces a "return" - completion -info: | - ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] - - [...] - 5. Let result be the result of performing - IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with - iteratorRecord as the argument - 6. 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). - - 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). -features: [Symbol.iterator, generators] -template: async-generator -esid: sec-runtime-semantics-destructuringassignmentevaluation ----*/ - -//- setup -function ReturnError() {} -var returnCount = 0; -var unreachable = 0; -var iterator = { - return() { - returnCount += 1; - - throw new Test262Error(); - } -}; -var iterable = { - [Symbol.iterator]() { - return iterator; - } -}; - -//- elems -[...{}[yield]] -//- vals -iterable -//- body -unreachable += 1; -//- teardown - -iter.next().then(() => { - assert.throws(Test262Error, () => iter.return()); - assert.sameValue(returnCount, 1); - assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); -}).then($DONE, $DONE); - diff --git a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-null.case b/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-null.case deleted file mode 100644 index 169c106f01963c302eb623ce5271f0c41019461e..0000000000000000000000000000000000000000 --- a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close-null.case +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2016 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 : [ Elisionopt AssignmentRestElement ] - - [...] - 5. Let result be the result of performing - IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with - iteratorRecord as the argument - 6. 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). - - 7.4.6 IteratorClose( iterator, completion ) - - [...] - 6. Let innerResult be Call(return, iterator, « »). - [...] - - 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). -features: [Symbol.iterator, generators] -template: async-generator -esid: sec-runtime-semantics-destructuringassignmentevaluation ----*/ - -//- setup -var iterable = {}; -var iterator = { - return() { - return null; - } -}; -var iterable = { - [Symbol.iterator]() { - return iterator; - } -}; - - -//- elems -[...{}[yield]] -//- vals -iterable -//- teardown - - -iter.next().then(() => { - assert.throws(Test262Error, () => iter.return()); - assert.sameValue(returnCount, 1); - assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); -}).then($DONE, $DONE); - diff --git a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close.case b/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close.case deleted file mode 100644 index ccb3e18914cd73386cb9881d0988ddcfa69f170b..0000000000000000000000000000000000000000 --- a/src/dstr-assignment-async-iteration/array-rest-iter-rtrn-close.case +++ /dev/null @@ -1,83 +0,0 @@ -// 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 reference evaluation produces a "return" - completion -info: | - ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] - - [...] - 5. Let result be the result of performing - IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with - iteratorRecord as the argument - 6. 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). - - 7.4.6 IteratorClose( iterator, completion ) - - [...] - 6. Let innerResult be Call(return, iterator, « »). - [...] - - 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). -features: [Symbol.iterator, generators] -template: async-generator -esid: sec-runtime-semantics-destructuringassignmentevaluation ----*/ - -//- setup -var returnCount = 0; -var unreachable = 0; -var thisValue = null; -var args = null; -var iterator = { - return() { - returnCount += 1; - thisValue = this; - args = arguments; - return {}; - } -}; -var iterable = { - [Symbol.iterator]() { - return iterator; - } -}; - -//- elems -[...{}[yield]] -//- vals -iterable -//- body -unreachable += 1; -//- teardown - - -iter.next().then(() => { - iter.return(444).then(result => { - assert.sameValue(returnCount, 1); - assert.sameValue(unreachable, 0, 'Unreachable statement was not executed'); - assert.sameValue(result.value, 444); - assert(result.done, 'Iterator correctly closed'); - assert.sameValue(thisValue, iterator, 'correct `this` value'); - assert(!!args, 'arguments object provided'); - assert.sameValue(args.length, 0, 'zero arguments specified'); - }).then($DONE, $DONE); -}); - - - - diff --git a/src/dstr-assignment-async-iteration/array-rest-iteration.case b/src/dstr-assignment-async-iteration/array-rest-iteration.case index fbe10e8a7fad6c1b8bcc48b9d3a546c70030b009..effa4f674440b09d4503a488600668622b7c1d50 100644 --- a/src/dstr-assignment-async-iteration/array-rest-iteration.case +++ b/src/dstr-assignment-async-iteration/array-rest-iteration.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,15 +11,15 @@ features: [generators] ---*/ //- setup -var count = 0; -var g = function*() { +let count = 0; +let g = function*() { count += 1; yield; count += 1; yield; count += 1; } -var x; +let x; //- elems [...x] //- vals @@ -27,4 +27,9 @@ g() //- body assert.sameValue(count, 3); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/array-rest-lref.case b/src/dstr-assignment-async-iteration/array-rest-lref.case index 35d2f347ca558a79bc93b5139798728eb17b977e..e4e2cc80e88d945e743aeb17977974c96725c430 100644 --- a/src/dstr-assignment-async-iteration/array-rest-lref.case +++ b/src/dstr-assignment-async-iteration/array-rest-lref.case @@ -1,4 +1,4 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. +// 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 @@ -6,11 +6,11 @@ info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] [...] - 5. Let result be the result of performing - IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with - iteratorRecord as the argument - 6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, - result). + 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 @@ -25,9 +25,9 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ //- setup -var nextCount = 0; -var returnCount = 0; -var iterator = { +let nextCount = 0; +let returnCount = 0; +let iterator = { next() { nextCount += 1; return { done: true }; @@ -36,8 +36,8 @@ var iterator = { returnCount += 1; } }; -var obj = {}; -var iterable = { +let obj = {}; +let iterable = { [Symbol.iterator]() { return iterator; } @@ -52,4 +52,8 @@ assert.sameValue(returnCount, 0); assert(!!obj.ab); assert.sameValue(obj.ab.length, 0); +//- teardown +iter.next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case index e44b1506a45c414b472d2f676cdbd6caaccb1c4a..9949ba9abf0c63ccf7d526c9c281443d6ca5dd53 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-null.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -10,7 +10,7 @@ template: default ---*/ //- setup -var x, y; +let x, y; //- elems [...[x, y]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case index a9dd40ff74bc1fb14a8221b4004b36ec67eb997b..850a1162ce93db8f33018795bfb6ade5576b256f 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-hole.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +let x = null; //- elems [...[x]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case index b8a5c809ac1e850644d5f4ba563f33b6fb27a5a1..8cb676ff6ed7c4e41e96391881ddc27a2760e2b5 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined-own.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +let x = null; //- elems [...[x]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case index 0acebafcdb65b31bd2eb403fb664c8041de270d1..6069e8969758050ee05e07ac5ba51114f9fc3933 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-undefined.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +let x = null; //- elems [...[x]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case index 384f1646f277b2811dc9ea87077ae96ec7690ceb..d3e60ed236ba2f7daf698c5fac49b05281947630 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-expr.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,8 +11,7 @@ features: [generators] ---*/ //- setup -var value = [86]; -var x = {}; +let x = {}; //- elems [...[x[yield]]] @@ -24,9 +23,7 @@ iter.next().then(iterationResult => { assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); - // TODO add iterCount - // - iter.next(86).then(iterationResult => { + iter.next('prop').then(iterationResult => { assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop, 86); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case index 486ca2a21322c4cbe7d1ea9c3103ca2fcb68fdb8..d9edb6dc66e7744245ea9bd5297960ff751ff883 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array-yield-ident-valid.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -6,13 +6,13 @@ 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: default +template: async-function flags: [noStrict] ---*/ //- setup -var yield = 'prop'; -var x = {}; +let yield = 'prop'; +let x = {}; //- elems [...[x[yield]]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-array.case b/src/dstr-assignment-async-iteration/array-rest-nested-array.case index 23286b13af16dad4514d0812fbc623bed72b08c1..2d9ae7b62a3777bb7688d55394bffc86856dcb1b 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-array.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-array.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x; +let x; //- elems [...[x]] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case index 505df0fd6a5d8a2daedf9149300a6e8c88adc5c0..fa38c07d1805bd85d61fb52070ccc77e05856164 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-null.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x, length; +let x, length; //- elems [...{ 0: x, length }] //- vals diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case index 7b6f5c0c417032c717986388ada8da3547fd2e02..1893815708e3c5f59056f414a91038af69dc1df0 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-hole.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +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; @@ -22,3 +22,8 @@ let length; //- body assert.sameValue(x, undefined); assert.sameValue(length, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case index 553a8e46bc024ee3b3c8230b0defc460e15f615b..fa864bc3d5f3c8e485990fe3206120a453253feb 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined-own.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +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; @@ -22,3 +22,8 @@ let length; //- body assert.sameValue(x, undefined); assert.sameValue(length, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case index 305df52c622e2f4fc44b8af6087fc643f9cf46ea..9723b02433394a589c6b38190dc45e12bf2b7c50 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-undefined.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,7 +11,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = null; +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; @@ -22,3 +22,8 @@ let length; //- body assert.sameValue(x, undefined); assert.sameValue(length, 0); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case index ed1afc7531aa8267c7c538b34adafc9c27abc03d..110ba07bf04784a9b5b5119ecc024471eb315e91 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-expr.case @@ -11,7 +11,7 @@ features: [generators] ---*/ //- setup -var x; +let x; //- elems [...{ x = yield }] @@ -23,8 +23,6 @@ iter.next().then(iterationResult => { assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); - // TODO add iterCount - // iter.next(4).then(iterationResult => { assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case index ecd104a23601063b3f3e9917f05ebf7a9235d377..12841d7d6a24129ff9098584baae05babb511562 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj-yield-ident-valid.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -6,16 +6,21 @@ 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: default +template: async-function flags: [noStrict] ---*/ //- setup -var yield = 2; -var x; +let yield = 2; +let x; //- elems [...{ x = yield }] //- vals [{}] //- body assert.sameValue(x, 2); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-nested-obj.case b/src/dstr-assignment-async-iteration/array-rest-nested-obj.case index 17ba9acedcf9d680319481aaca87d8a95b8d6267..c248030593fb933c765ff6a5ee4622b9e0563c5b 100644 --- a/src/dstr-assignment-async-iteration/array-rest-nested-obj.case +++ b/src/dstr-assignment-async-iteration/array-rest-nested-obj.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -10,10 +10,14 @@ template: default ---*/ //- setup -var x; +let x; //- elems [...{ 1: x }] //- vals [1, 2, 3] //- body assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case index 1adb2c2e07d0f7fb7435ed9de27050395588a38b..0a2daa2d56f943040f26ff04c7d8d436c197695b 100644 --- a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case +++ b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref-no-get.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -10,8 +10,8 @@ es6id: 12.14.5.3 ---*/ //- setup -var setValue; -var x = { +let setValue; +let x = { get y() { $ERROR('The property should not be accessed.'); }, @@ -28,3 +28,7 @@ assert.sameValue(setValue.length, 3); assert.sameValue(setValue[0], 23); assert.sameValue(setValue[1], 45); assert.sameValue(setValue[2], 99); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case index fda1af6dc0065c6333a52af541f082e861e2ffe3..4af124f33665a61aac0bf84b462173b0779ef014 100644 --- a/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case +++ b/src/dstr-assignment-async-iteration/array-rest-put-prop-ref.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -10,7 +10,7 @@ es6id: 12.14.5.3 ---*/ //- setup -var x = {}; +let x = {}; //- elems [...x.y] //- vals @@ -20,3 +20,7 @@ assert.sameValue(x.y.length, 3); assert.sameValue(x.y[0], 4); assert.sameValue(x.y[1], 3); assert.sameValue(x.y[2], 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case index 7f3ac5769bfdb03abdbf0489abbcc5718c7027a7..f7221ff117aae812c5bdbe3d8b6beda0c51b71b9 100644 --- a/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case +++ b/src/dstr-assignment-async-iteration/array-rest-put-unresolvable-no-strict.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -14,5 +14,8 @@ flags: [noStrict] //- vals [] //- body - assert.sameValue(unresolvable.length, 0); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/array-rest-yield-expr.case b/src/dstr-assignment-async-iteration/array-rest-yield-expr.case index 1953e20e3691fdab7bef0bbf83ed6557c09bdff2..acc1dcb7901544ddf9358ecaa82a337f4f92ab25 100644 --- a/src/dstr-assignment-async-iteration/array-rest-yield-expr.case +++ b/src/dstr-assignment-async-iteration/array-rest-yield-expr.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,21 +11,18 @@ features: [generators] ---*/ //- setup -var x = {}; +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); - // TODO add iterCount - // iter.next('prop').then(iterationResult => { assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); @@ -33,5 +30,7 @@ iter.next().then(iterationResult => { assert.sameValue(x.prop[0], 33); assert.sameValue(x.prop[1], 44); assert.sameValue(x.prop[2], 55); + assert.sameValue(iterCount, 1); }).then($DONE, $DONE); }); + diff --git a/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case b/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case index 44727057c9d3df38e47207ceb8550a39dcb02aa4..9d3319a38ca16621a8a94f2ab88b982d762aa715 100644 --- a/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case +++ b/src/dstr-assignment-async-iteration/array-rest-yield-ident-valid.case @@ -1,4 +1,4 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -11,8 +11,8 @@ flags: [noStrict] ---*/ //- setup -var yield = 'prop'; -var x = {}; +let yield = 'prop'; +let x = {}; //- elems [...x[yield]] //- vals @@ -22,3 +22,9 @@ assert.sameValue(x.prop.length, 3); assert.sameValue(x.prop[0], 33); assert.sameValue(x.prop[1], 44); assert.sameValue(x.prop[2], 55); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template b/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..a6d537c9eedc0743e1a4f410ad7720e5f92790ea --- /dev/null +++ b/src/dstr-assignment-async-iteration/error-async-function-syntax/async-func-decl.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) +} diff --git a/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template b/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..90fe373fb19491fd02b6c154bb5a57ff5c2aa717 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error-async-generator-syntax/async-gen-decl.template @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) +} diff --git a/src/dstr-assignment-async-iteration/error/async-func-decl.template b/src/dstr-assignment-async-iteration/error/async-func-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..0fd7dffec0e0b5f971f8330120381fb14b32dfc8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error/async-func-decl.template @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-decl-dstr- +name: for-await-of statement in an async function declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + } +} + +let promise = fn(); diff --git a/src/dstr-assignment-async-iteration/error/async-gen-decl.template b/src/dstr-assignment-async-iteration/error/async-gen-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..47425432f5de26a289ac3346d36e5ef23e75e3f6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/error/async-gen-decl.template @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-decl-dstr- +name: for-await-of statement in an async generator declaration +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 5. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +async function * fn() { + for await (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + } +} + +let promise = fn().next(); + diff --git a/src/dstr-assignment-async-iteration/obj-empty-bool.case b/src/dstr-assignment-async-iteration/obj-empty-bool.case new file mode 100644 index 0000000000000000000000000000000000000000..b7515ae5888cd2ea8b1f8e08916ca824f54fe701 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-bool.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (boolean value) +template: default +---*/ + +//- elems +{} +//- vals +false +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-num.case b/src/dstr-assignment-async-iteration/obj-empty-num.case new file mode 100644 index 0000000000000000000000000000000000000000..de42463600f03bd28a3351f11f9150db472f70d2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-num.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (number value) +template: default +---*/ + +//- elems +{} +//- vals +0 + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-obj.case b/src/dstr-assignment-async-iteration/obj-empty-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..aa4e88ed14e5a90a9bd823bed872b51bbf3ea367 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-obj.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (object value) +template: default +---*/ + +//- elems +{} +//- vals +{} +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-string.case b/src/dstr-assignment-async-iteration/obj-empty-string.case new file mode 100644 index 0000000000000000000000000000000000000000..2531e7af9377c32240c4ea2a12cc5547ed0a061b --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-string.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (string value) +template: default +---*/ + +//- elems +{} +//- vals +'' +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-empty-symbol.case b/src/dstr-assignment-async-iteration/obj-empty-symbol.case new file mode 100644 index 0000000000000000000000000000000000000000..6dff904138782b2c36607717a6e9aef122bf6345 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-empty-symbol.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ObjectAssignmentPattern without an AssignmentPropertyList requires an + object-coercible value (symbol value) +template: default +features: [Symbol] +---*/ + +//- setup +let s = Symbol(); +//- elems +{} +//- vals +s +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..2e7f0ffbea0f22be3dddb481a383e45c3a341eb6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-first.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (first of many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let y; +//- elems +{ x, y } +//- vals +{ x: 3 } +//- body +assert.sameValue(x, 3); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..891a39bf9a4245382a2295e405201820bc41e662 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-last.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (last of many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w; +//- elems +{ w, x } +//- vals +{ x: 4 } +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..e587e08cba462be3b22df3e936ffe8a380729457 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-lone.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone identifier) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ x, } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..e18d9874553bdb535624f286b2889aa745486cc2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-middle.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (within many) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w, y; +//- elems +{ w, x, y } +//- vals +{ x: 5 } +//- body +assert.sameValue(x, 5); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..baff69ebd8832a8f3b6ec814cca0c6341d3b855e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-identifier-resolution-trlng.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone identifier with trailing + comma) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ x } +//- vals +{ x: 1 } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..35af6aaad6b63f624cf9d0aedc3f1da1ee476c09 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-missing.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (no corresponding + property defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..363aa9efc2d107727d5829475dbcc4bf99e7eb24 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-null.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (null property + value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: null } +//- body +assert.sameValue(x, null); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..135149127ae734f7e8751155372ff6bb3bcd8604 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-truthy.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (truthy property + value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case b/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..2eaea90f40c71b3bcfdeb14e9d28563a54b71c0d --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-assignment-undef.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference ("undefined" + property value defined). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ x = 1 } +//- vals +{ x: undefined } +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case b/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..be1928c8b759fc5d8fd80efded07ae3a2eae89af --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-evaluation.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer should only be evaluated if v is undefined. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let flag1 = false; +let flag2 = false; +let x, y; +//- elems +{ x = flag1 = true, y = flag2 = true } +//- vals +{ y: 1 } +//- body +assert.sameValue(flag1, true); +assert.sameValue(flag2, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case new file mode 100644 index 0000000000000000000000000000000000000000..ffac568e75332a1f21f6fd6e16ab4d983bb6439f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-arrow.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ArrowFunction) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let arrow; +//- elems +{ arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); +verifyNotEnumerable(arrow, 'name'); +verifyNotWritable(arrow, 'name'); +verifyConfigurable(arrow, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case new file mode 100644 index 0000000000000000000000000000000000000000..36e269e8675eb6bb7d8685282eb988d8479eabab --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-class.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ClassExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xCls, cls, xCls2; +//- elems +{ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); + +assert.sameValue(cls.name, 'cls'); +verifyNotEnumerable(cls, 'name'); +verifyNotWritable(cls, 'name'); +verifyConfigurable(cls, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case new file mode 100644 index 0000000000000000000000000000000000000000..3f398fa41577a18c5578c6dc47356aecd0b2af72 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-cover.case @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let xCover, cover; +//- elems +{ xCover = (0, function() {}), cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); + +assert.sameValue(cover.name, 'cover'); +verifyNotEnumerable(cover, 'name'); +verifyNotWritable(cover, 'name'); +verifyConfigurable(cover, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case new file mode 100644 index 0000000000000000000000000000000000000000..7c931ef72c9015f32b35d7f7669ed829134888ce --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-fn.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (FunctionExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +---*/ + +//- setup +let xFnexp, fnexp; +//- elems +{ xFnexp = function x() {}, fnexp = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFnexp.name, 'xFnexp'); + +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case new file mode 100644 index 0000000000000000000000000000000000000000..da5c52c5b705eedee5ea74d5282bfc6cb169fb75 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-fn-name-gen.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default +es6id: 12.14.5.2 +info: > + AssignmentProperty : IdentifierReference Initializeropt + + [...] + 6. If Initializeropt is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, P). +includes: [propertyHelper.js] +features: [generators] +---*/ + +//- setup +let xGen, gen; +//- elems +{ xGen = function* x() {}, gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); + +assert.sameValue(gen.name, 'gen'); +verifyNotEnumerable(gen, 'name'); +verifyNotWritable(gen, 'name'); +verifyConfigurable(gen, 'name'); + + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-in.case b/src/dstr-assignment-async-iteration/obj-id-init-in.case new file mode 100644 index 0000000000000000000000000000000000000000..548ede4bec6b3adda33a8656f4c7a91390a585c9 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-in.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer in an AssignmentProperty may be an `in` expression. +template: default +es6id: 12.14.5 +---*/ + +//- setup +let prop; +//- elems +{ prop = 'x' in {} } +//- vals +{} +//- body +assert.sameValue(prop, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-order.case b/src/dstr-assignment-async-iteration/obj-id-init-order.case new file mode 100644 index 0000000000000000000000000000000000000000..a5c60545b2e1bb0afef4c973c0e9c45ee3e1b5d4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-order.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Initializer values should be assigned in left-to-right order. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = 0; +let a, b; +//- elems +{ a = x += 1, b = x *= 2 } +//- vals +{} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..badf346f9282bf12dc7cb92774fb27096df18ef2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-simple-no-strict.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let eval, arguments; +//- elems +{ eval = 3, arguments = 4 } +//- vals +{} +//- body +assert.sameValue(eval, 3); +assert.sameValue(arguments, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case b/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..dbd2aaaed0940beef1a835be492ac4996604128a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentProperty and within a generator function body, it should behave + as a YieldExpression. +template: async-generator +es6id: 12.14.5 +features: [generators] +---*/ + +//- setup +let x; + +//- elems +{ x = yield } +//- vals +{} +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(3).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 3); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..c7d2db9c9dc8d91f03c79afe0d6dd58e402640df --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-init-yield-ident-valid.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an + AssignmentProperty and outside of a generator function body, it should + behave as an IdentifierReference. +template: async-function +es6id: 12.14.5 +flags: [noStrict] +---*/ + +//- setup +let yield = 3; +let x; +//- elems +{ x = yield } +//- vals +{} +//- body +assert.sameValue(x, 3); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..ea28e25faad39205b90c2e2b7aca6e081f223d79 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-put-unresolvable-no-strict.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +{ +//- elems +{ unresolvable } +//- vals +{} +//- teardown +promise + .then(() => { + assert.sameValue(unresolvable, undefined); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); +} diff --git a/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case b/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..bbff2331c6db067108c4fff60d792c77ea8aa11c --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-id-simple-no-strict.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let eval; +//- elems +{ eval } +//- vals +{ eval: 1 } +//- teardown +promise + .then(() => { + assert.sameValue(eval, 1); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..444385fd34df13db07897fe141ad40fa6bc64016 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-missing.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (non-existent + property) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..0c41d3a32cc3a4cff87e6ff8f8e5bb0fc096aad7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-null.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is not undefined, the Initializer should + be evaluated and the result assigned to the target reference (null value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: null } +//- body +assert.sameValue(x, null); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..575026770b50a47a6fac48b08e55fa8468116895 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-truthy.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is not undefined, the Initializer should + be evaluated and the result assigned to the target reference (truthy value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..947dbcd2a3a99c81c6d707b29a32fe7722842c9f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-assignment-undef.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference (undefined value) +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ y: x = 1 } +//- vals +{ y: undefined } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..cdca15202c65b6d3f81fbcf216f5ed59ac212c94 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-evaluation.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer should only be evaluated if v is undefined. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let flag1 = false; +let flag2 = false; +let x, y; +//- elems +{ x: x = flag1 = true, y: y = flag2 = true } +//- vals +{ y: 1 } +//- body +assert.sameValue(x, true, 'value of `x`'); +assert.sameValue(flag1, true, 'value of `flag1`'); +assert.sameValue(y, 1, 'value of `y`'); +assert.sameValue(flag2, false, 'value of `flag2`'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case new file mode 100644 index 0000000000000000000000000000000000000000..1fe46df9477e87e35166ef9904870ddf620b3899 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-arrow.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ArrowFunction) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let arrow; +//- elems +{ x: arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); +verifyNotEnumerable(arrow, 'name'); +verifyNotWritable(arrow, 'name'); +verifyConfigurable(arrow, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case new file mode 100644 index 0000000000000000000000000000000000000000..a5ba2e3a050976d3a63f29267f85035a01d8bc05 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-class.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (ClassExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [class] +---*/ + +//- setup +let xCls, cls, xCls2; +//- elems +{ x: xCls = class x {}, x: cls = class {}, x: xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); + +assert.sameValue(cls.name, 'cls'); +verifyNotEnumerable(cls, 'name'); +verifyNotWritable(cls, 'name'); +verifyConfigurable(cls, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case new file mode 100644 index 0000000000000000000000000000000000000000..dc28778daed69d5560036867b87b8e5fef4fdda6 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-cover.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let xCover, cover; +//- elems +{ x: xCover = (0, function() {}), x: cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); + +assert.sameValue(cover.name, 'cover'); +verifyNotEnumerable(cover, 'name'); +verifyNotWritable(cover, 'name'); +verifyConfigurable(cover, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case new file mode 100644 index 0000000000000000000000000000000000000000..bb4478d34c1f5f4a469974f3e334a641e85726d5 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-fn.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (FunctionExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +---*/ + +//- setup +let xFnexp, fnexp; +//- elems +{ x: xFnexp = function x() {}, x: fnexp = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFnexp.name, 'xFnexp'); + +assert.sameValue(fnexp.name, 'fnexp'); +verifyNotEnumerable(fnexp, 'name'); +verifyNotWritable(fnexp, 'name'); +verifyConfigurable(fnexp, 'name'); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case new file mode 100644 index 0000000000000000000000000000000000000000..b9f7fc89c71fb67bdfd8ca57296b6e59bcbd6f71 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-fn-name-gen.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default +es6id: 12.14.5.4 +info: > + AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt + + [...] + 6. If Initializer is present and v is undefined and + IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of + DestructuringAssignmentTarget are both true, then + a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)). +includes: [propertyHelper.js] +features: [generators] +---*/ + +//- setup +let xGen, gen; +//- elems +{ x: xGen = function* x() {}, x: gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); + +assert.sameValue(gen.name, 'gen'); +verifyNotEnumerable(gen, 'name'); +verifyNotWritable(gen, 'name'); +verifyConfigurable(gen, 'name'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case new file mode 100644 index 0000000000000000000000000000000000000000..ebde862cbed384d264b611f6b5cc37f6dabfc357 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-in.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The Initializer in an AssignmentElement may be an `in` expression. +template: default +es6id: 12.14.5 +---*/ + +//- setup +let prop; +//- elems +{ x: prop = 'x' in {} } +//- vals +{} +//- body +assert.sameValue(prop, false); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..0d01eb80fed70660f66fb2e0e348800050505feb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + and within a generator function body, it should behave as a + YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x; +//- elems +{ x: x = yield } +//- vals +{} +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(86).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 86); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..b06c24651f447b32a1b74fcf896f120516dd8ad3 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-init-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of an AssignmentElement + and outside of a generator function body, it should behave as an + IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 4; +let x; +//- elems +{ x: x = yield } +//- vals +{} +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..10f4b54792cde8a8b9433dd9243a847b7a780164 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-expr.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and within a generator function body, it should behave as + a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x = {}; +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x.prop, undefined); + + iter.next('prop').then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x.prop, 23); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..04f9038968c1965b1bdf796f665426bce3d17be9 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-elem-target-yield-ident-valid.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the DestructuringAssignmentTarget of an + AssignmentElement and outside of a generator function body, it should + behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 'prop'; +let x = {}; +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- body +assert.sameValue(x.prop, 23); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..226bdc79fa56c48d6afe84dad65db3fa2d8993f0 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-first.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (first of many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let y; +//- elems +{ a: x, y } +//- vals +{ a: 3 } +//- body +assert.sameValue(x, 3); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..3efb3d355160de194e6c2b1d9952d7ccc1893ea7 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-last.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (last of many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w; +//- elems +{ w, a: x } +//- vals +{ a: 4 } +//- body +assert.sameValue(x, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..fec596e5a98ab348d06f8b0bb0dc1e33c1c20d8c --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-lone.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone element). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ a: x } +//- vals +{ a: 1 } +//- body +assert.sameValue(x, 1); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..f78417284063e751c416bff02dc9545ce35c54fb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-middle.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (within many). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +let w, y; +//- elems +{ w, a: x, y } +//- vals +{ a: 5 } +//- body +assert.sameValue(x, 5); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..c38a146cef089cff2df328d3a227a7939aa07f3a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-identifier-resolution-trlng.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Evaluation of DestructuringAssignmentTarget (lone element with trailing + comma). +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = null; +//- elems +{ a: x, } +//- vals +{ a: 2 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case b/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..e40d850af342b0866077b63bcf0cec0003896707 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-name-evaluation.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + PropertyName of an AssignmentProperty may be a ComputedPropertyName. +template: default +es6id: 12.14.5.2 +---*/ + +//- setup +let x, y, xy; +//- elems +{ ['x' + 'y']: x } +//- vals +{ x: 1, xy: 23, y: 2 } +//- body +assert.sameValue(x, 23); +assert.sameValue(y, undefined); +assert.sameValue(xy, undefined); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..32748683bb3f31e7d00b0c643b160ec0fca26a30 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it should + behave as a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x; + +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(24601).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 24601); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..5ebe36dddae934cdf6be48dc0fa190d10a2791ef --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and outside of a generator function body, it + should behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 22; +let x; +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- body +assert.sameValue(x, 22); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-array.case b/src/dstr-assignment-async-iteration/obj-prop-nested-array.case new file mode 100644 index 0000000000000000000000000000000000000000..daa41735ef11c632d0762eb87cdf85d8c92626a2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-array.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an array literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let y; +//- elems +{ x: [y] } +//- vals +{ x: [321] } +//- body +assert.sameValue(y, 321); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case new file mode 100644 index 0000000000000000000000000000000000000000..4124cd5a3d0821d6c021e1ae69b153777e522df4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-expr.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and within a generator function body, it should + behave as a YieldExpression. +template: async-generator +es6id: 12.14.5.4 +features: [generators] +---*/ + +//- setup +let x = undefined; + +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- teardown +iter.next().then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, false); + assert.sameValue(x, undefined); + + iter.next(4).then(result => { + assert.sameValue(result.value, undefined); + assert.sameValue(result.done, true); + assert.sameValue(x, 4); + }).then($DONE, $DONE); +}); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..5d6f65813d96690ad59823a036da3ee337155079 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj-yield-ident-valid.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When a `yield` token appears within the Initializer of a nested + destructuring assignment and outside of a generator function body, it + should behave as an IdentifierReference. +template: async-function +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +let yield = 2; +let result, x; +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case b/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..12ee4ff1eb3f937c734c8ce2c9ea96aad2218025 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-nested-obj.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let result, y; +//- elems +{ x: { y } } +//- vals +{ x: { y: 2 } } +//- body +assert.sameValue(y, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-order.case b/src/dstr-assignment-async-iteration/obj-prop-put-order.case new file mode 100644 index 0000000000000000000000000000000000000000..ad84d95b1edd26ce4d2039bc3a3631d7465f9360 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-order.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The AssignmentElements in an AssignmentElementList are evaluated in left- + to-right order. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x; +//- elems +{ z: x, a: x } +//- vals +{ a: 2, z: 1 } +//- body +assert.sameValue(x, 2); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case new file mode 100644 index 0000000000000000000000000000000000000000..3e1bbaffb6d75ac76476e29a67108797345f78d2 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref-no-get.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the DestructuringAssignmentTarget of an AssignmentElement is a + PropertyReference, it should not be evaluated. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let setValue; +let x = { + get y() { + $ERROR('The property should not be accessed.'); + }, + set y(val) { + setValue = val; + } +}; +//- elems +{ a: x.y } +//- vals +{ a: 23 } +//- body +assert.sameValue(setValue, 23); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case new file mode 100644 index 0000000000000000000000000000000000000000..1e2f676de1c4841ed7ebb548cb92440bd71f75b4 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-prop-ref.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + The DestructuringAssignmentTarget of an AssignmentElement may be a + PropertyReference. +template: default +es6id: 12.14.5.4 +---*/ + +//- setup +let x = {}; +//- elems +{ xy: x.y } +//- vals +{ xy: 4 } +//- body +assert.sameValue(x.y, 4); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case b/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..cdcebfb97c0900b8542d030c2e5849b132e0b31a --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-prop-put-unresolvable-no-strict.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Outside of strict mode, if the the assignment target is an unresolvable + reference, a new `var` binding should be created in the environment record. +template: default +es6id: 12.14.5.4 +flags: [noStrict] +---*/ + +//- setup +{ +//- elems +{ x: unresolvable } +//- vals +{} +//- teardown +promise + .then(() => { + assert.sameValue(unresolvable, undefined); + assert.sameValue(iterCount, 1, 'iteration occurred as expected'); + }, $DONE) + .then($DONE, $DONE); +} diff --git a/src/dstr-assignment-async-iteration/obj-rest-descriptors.case b/src/dstr-assignment-async-iteration/obj-rest-descriptors.case new file mode 100644 index 0000000000000000000000000000000000000000..b61100602536e9d9b274ac7dd98983813f210ec8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-descriptors.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Object created from rest deconstruction doesn't copy source + object property descriptors. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest; +let obj = {}; +Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true }); +Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true }); +//- elems +{...rest} +//- vals +obj +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case b/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..9cc4fe330268327acf1510834099ffe1aa04c51f --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-empty-obj.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object even if lhs is an empty object +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +{} +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert.sameValue(typeof rest, "object"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-getter.case b/src/dstr-assignment-async-iteration/obj-rest-getter.case new file mode 100644 index 0000000000000000000000000000000000000000..6a3b38a2279634f53186713a792ce23c046f5373 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-getter.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Getter is called when obj is being deconstructed to a rest Object +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let x; +let count = 0; +//- elems +{...x} +//- vals +{ get v() { count++; return 2; } } +//- body +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case b/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case new file mode 100644 index 0000000000000000000000000000000000000000..716958f7e4feb40122c31cbd4a0fee18e6e6c460 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-nested-obj-nested-rest.case @@ -0,0 +1,40 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment and object rest desconstruction is allowed in that case. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let a, b, c, rest; +//- elems +{a, b, ...{c, ...rest}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case b/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..e2b18b84b85b930ac222589ba02222e9cf23cc06 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-nested-obj.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let a, b, c, d, e; +//- elems +{a, b, ...{c, e}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); +assert.sameValue(d, undefined); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-number.case b/src/dstr-assignment-async-iteration/obj-rest-number.case new file mode 100644 index 0000000000000000000000000000000000000000..44bfa8e7ba86aeb1d427c25694452d2be9e44acd --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-number.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object even if lhs is a Number +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +51 +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case b/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case new file mode 100644 index 0000000000000000000000000000000000000000..e804894b202b5673c0995d2fbaedaa64a8e8e6ea --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-obj-own-property.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just source object's own properties +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +let x, y, z; +//- elems +{ x, ...{y , z} } +//- vals +o +//- body +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-same-name.case b/src/dstr-assignment-async-iteration/obj-rest-same-name.case new file mode 100644 index 0000000000000000000000000000000000000000..4906ffbb3b8ff29c2ed79e2ff25a2b0197b9f41e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-same-name.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Proper setting in the values for rest name equal to a property name. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let o = { + x: 42, + y: 39, + z: 'cheeseburger' +}; + +let x, y, z; +//- elems +{ x, ...z } +//- vals +o +//- body +assert.sameValue(x, 42); +assert.sameValue(y, undefined); +assert.sameValue(z.y, 39); +assert.sameValue(z.z, 'cheeseburger'); + +let keys = Object.keys(z); +assert.sameValue(keys.length, 2); +assert.sameValue(keys[0], 'y'); +assert.sameValue(keys[1], 'z'); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case b/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case new file mode 100644 index 0000000000000000000000000000000000000000..a38daa7a96f14b824612b0fb344f09a5d6fc5d23 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-skip-non-enumerable.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object doesn't contain non-enumerable properties +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest; +let obj = {a: 3, b: 4}; +Object.defineProperty(obj, "x", { value: 4, enumerable: false }); +//- elems +{...rest} +//- vals +obj +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-str-val.case b/src/dstr-assignment-async-iteration/obj-rest-str-val.case new file mode 100644 index 0000000000000000000000000000000000000000..ef575bf556dbd2efc98709b4b21490b1a6a4b704 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-str-val.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creats an object with indexes as property name +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +"foo" +//- body +assert.sameValue(rest["0"], "f"); +assert.sameValue(rest["1"], "o"); +assert.sameValue(rest["2"], "o"); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case b/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case new file mode 100644 index 0000000000000000000000000000000000000000..4feed1a46499c0496da204e81c42c2bed0c7671e --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-symbol-val.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + RestBindingInitialization creates a new object if lhs is a Symbol +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let rest; + +//- elems +{...rest} +//- vals +Symbol("foo") +//- body +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case b/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case new file mode 100644 index 0000000000000000000000000000000000000000..d5db125a097e71c53f93e50b7ca707916948cfec --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-to-property-with-setter.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object property setter, its value should be + binded as rest object. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +let settedValue; +let executedGetter = false; +let src = { + get y() { + executedGetter = true; + }, + set y(v) { + settedValue = v; + }, +}; +src.y = undefined; +//- elems +{...src.y} +//- vals +{ x: 1, y: 2} +//- body +assert.sameValue(settedValue.x, 1); +assert.sameValue(settedValue.y, 2); +assert(!executedGetter, "The property should not be accessed"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-to-property.case b/src/dstr-assignment-async-iteration/obj-rest-to-property.case new file mode 100644 index 0000000000000000000000000000000000000000..fff09d20e8f00732fbc0eb59025878910b3ee1c8 --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-to-property.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object property, its value should be binded + as rest object. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let src = {}; +//- elems +{...src.y} +//- vals +{ x: 1, y: 2} +//- body +assert.sameValue(src.y.x, 1); +assert.sameValue(src.y.y, 2); + +verifyEnumerable(src, "y"); +verifyWritable(src, "y"); +verifyConfigurable(src, "y"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-assignment-async-iteration/obj-rest-valid-object.case b/src/dstr-assignment-async-iteration/obj-rest-valid-object.case new file mode 100644 index 0000000000000000000000000000000000000000..f959b8bbdc496c3222e494408470ad19dc60fccb --- /dev/null +++ b/src/dstr-assignment-async-iteration/obj-rest-valid-object.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Caio Lima & the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just unextracted data +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +let rest, a, b; + +//- elems +{a, b, ...rest} +//- vals +{x: 1, y: 2, a: 5, b: 3} +//- body +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + +//- teardown +promise + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE);