diff --git a/src/dstr-assignment/array-elem-init-assignment.case b/src/dstr-assignment/array-elem-init-assignment.case new file mode 100644 index 0000000000000000000000000000000000000000..a03405902ac7e081dcbef823a4fe167333cbc553 --- /dev/null +++ b/src/dstr-assignment/array-elem-init-assignment.case @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + If the Initializer is present and v is undefined, the Initializer should be + evaluated and the result assigned to the target reference. +template: default +es6id: 12.14.5.3 +---*/ + +//- setup +var v2, vNull, vHole, vUndefined, vOob; +//- elems +[v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] +//- vals +[2, null, , undefined] +//- body +assert.sameValue(v2, 2); +assert.sameValue(vNull, null); +assert.sameValue(vHole, 12); +assert.sameValue(vUndefined, 13); +assert.sameValue(vOob, 14); diff --git a/src/dstr-assignment/array-elem-init-evaluation.case b/src/dstr-assignment/array-elem-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..5feea93a8e01fb0517d983c63dcc29df363ebb13 --- /dev/null +++ b/src/dstr-assignment/array-elem-init-evaluation.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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.3 +---*/ + +//- setup +var flag1 = false, flag2 = false; +var _; +//- elems +[ _ = flag1 = true, _ = flag2 = true ] +//- vals +[14] +//- body +assert.sameValue(flag1, false); +assert.sameValue(flag2, true); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-arrow.js b/src/dstr-assignment/array-elem-init-fn-name-arrow.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-elem-init-fn-name-arrow.js rename to src/dstr-assignment/array-elem-init-fn-name-arrow.case index d729c2a89552efd20f32fcb020f3e75368b7821b..75d60e512aaa97d92e3c21a61e13c747c40fe487 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-arrow.js +++ b/src/dstr-assignment/array-elem-init-fn-name-arrow.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ArrowFunction) +desc: Assignment of function `name` attribute (ArrowFunction) +template: default es6id: 12.14.5.3 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -18,10 +19,13 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var arrow; - -[ arrow = () => {} ] = []; - +//- elems +[ arrow = () => {} ] +//- vals +[] +//- body assert.sameValue(arrow.name, 'arrow'); verifyNotEnumerable(arrow, 'name'); verifyNotWritable(arrow, 'name'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-class.js b/src/dstr-assignment/array-elem-init-fn-name-class.case similarity index 84% rename from test/language/expressions/assignment/destructuring/array-elem-init-fn-name-class.js rename to src/dstr-assignment/array-elem-init-fn-name-class.case index d781dd593cbbb6dd3c3c9c6a85cd07caed1b44fc..91be890976b6c2b51d49e39e6c2e1433de85ec53 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-class.js +++ b/src/dstr-assignment/array-elem-init-fn-name-class.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ClassExpression) +desc: Assignment of function `name` attribute (ClassExpression) +template: default es6id: 12.14.5.3 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,11 +20,13 @@ includes: [propertyHelper.js] features: [class] ---*/ +//- setup var xCls, cls; - -[ xCls = class x {} ] = [];; -[ cls = class {} ] = []; - +//- elems +[ xCls = class x {},cls = class {} ] +//- vals +[] +//- body assert(xCls.name !== 'xCls'); assert.sameValue(cls.name, 'cls'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-cover.js b/src/dstr-assignment/array-elem-init-fn-name-cover.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-elem-init-fn-name-cover.js rename to src/dstr-assignment/array-elem-init-fn-name-cover.case index 4e4b39351666d7d991d79e76f1876a52b37254e3..43cb3694819c2014d26359884599613dd43b5fcb 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-cover.js +++ b/src/dstr-assignment/array-elem-init-fn-name-cover.case @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default es6id: 12.14.5.3 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,11 +20,13 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var xCover, cover; - -[ xCover = (0, function() {}) ] = []; -[ cover = (function() {}) ] = []; - +//- elems +[ xCover = (0, function() {}), cover = (function() {}) ] +//- vals +[] +//- body assert(xCover.name !== 'xCover'); assert.sameValue(cover.name, 'cover'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-fn.js b/src/dstr-assignment/array-elem-init-fn-name-fn.case similarity index 83% rename from test/language/expressions/assignment/destructuring/array-elem-init-fn-name-fn.js rename to src/dstr-assignment/array-elem-init-fn-name-fn.case index 70e29b56ab4a5a4a77cade15634e77f5ef9eee75..4493b8e04380edf3f4d80bb616d7c6e57d9469c5 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-fn.js +++ b/src/dstr-assignment/array-elem-init-fn-name-fn.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (FunctionExpression) +desc: Assignment of function `name` attribute (FunctionExpression) +template: default es6id: 12.14.5.3 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,11 +20,13 @@ includes: [propertyHelper.js] features: [class] ---*/ +//- setup var xFn, fn; - -[ xFn = function x() {} ] = [];; -[ fn = function() {} ] = []; - +//- elems +[ xFn = function x() {}, fn = function() {} ] +//- vals +[] +//- body assert(xFn.name !== 'xFn'); assert.sameValue(fn.name, 'fn'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-gen.js b/src/dstr-assignment/array-elem-init-fn-name-gen.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-elem-init-fn-name-gen.js rename to src/dstr-assignment/array-elem-init-fn-name-gen.case index 0d17fc64903eeca3af21e7997378bc09ae05f4fa..fea3bbaa2e5b9ed9b5ef857b427d73345dfc4f02 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-fn-name-gen.js +++ b/src/dstr-assignment/array-elem-init-fn-name-gen.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (GeneratorExpression) +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default es6id: 12.14.5.3 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,12 +20,14 @@ includes: [propertyHelper.js] features: [generators] ---*/ +//- setup var xGen, gen; - -[ xGen = function* x() {} ] = []; -[ gen = function*() {} ] = [];; - -assert(xGen.name !== 'xGen'); +//- elems +[ xGen = function* x() {}, gen = function*() {} ] +//- vals +[] +//- body +assert.notSameValue(xGen.name, 'xGen'); assert.sameValue(gen.name, 'gen'); verifyNotEnumerable(gen, 'name'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-in.js b/src/dstr-assignment/array-elem-init-in.case similarity index 69% rename from test/language/expressions/assignment/destructuring/array-elem-init-in.js rename to src/dstr-assignment/array-elem-init-in.case index 8fddbff152d9cec041fa8b283135ccc38c478b33..d3afbe2760a4bea3112afbc18ab3ef8f4be45020 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-in.js +++ b/src/dstr-assignment/array-elem-init-in.case @@ -2,15 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The Initializer in an AssignmentElement may be an `in` expression. +template: default es6id: 12.14.5 ---*/ -var value = []; -var result, x; - -result = [ x = 'x' in {} ] = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +[ x = 'x' in {} ] +//- vals +[] +//- body assert.sameValue(x, false); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-let.js b/src/dstr-assignment/array-elem-init-let.case similarity index 69% rename from test/language/expressions/assignment/destructuring/array-elem-init-let.js rename to src/dstr-assignment/array-elem-init-let.case index b11f14491fcfa4c17048966d19267916e145a788..b3b8aea289e751eb464869c0e2de820e30981cf2 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-let.js +++ b/src/dstr-assignment/array-elem-init-let.case @@ -2,15 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Value retrieval of Initializer obeys `let` semantics. +template: error es6id: 12.14.5.3 features: [let] ---*/ +//- error +ReferenceError +//- setup var x; - -assert.throws(ReferenceError, function() { - [ x = y ] = []; - let y; -}); +//- elems +[ x = y ] +//- vals +[] +//- teardown +let y; diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-order.js b/src/dstr-assignment/array-elem-init-order.case similarity index 71% rename from test/language/expressions/assignment/destructuring/array-elem-init-order.js rename to src/dstr-assignment/array-elem-init-order.case index 43ff62a45631e3b40938a3a906d94cb5742f0978..f6e4830241995469e54622fe8d7b04850d1ca91e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-order.js +++ b/src/dstr-assignment/array-elem-init-order.case @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Initializer values should be assigned in left-to-right order. +template: default es6id: 12.14.5.3 ---*/ -var value = []; +//- setup var x = 0; -var a, b, result; - -result = [ a = x += 1, b = x *= 2 ] = value; - -assert.sameValue(result, value); +var a, b; +//- elems +[ a = x += 1, b = x *= 2 ] +//- vals +[] +//- body assert.sameValue(a, 1); assert.sameValue(b, 2); assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-simple-no-strict.js b/src/dstr-assignment/array-elem-init-simple-no-strict.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-elem-init-simple-no-strict.js rename to src/dstr-assignment/array-elem-init-simple-no-strict.case index b3a5e9c73c9d73f0eed0ba5aa7545c18fcc0ef7d..200238d079b7bb4337dd2710439ab8a59484dd5f 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-simple-no-strict.js +++ b/src/dstr-assignment/array-elem-init-simple-no-strict.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. +template: default es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = []; -var result, argument, eval; - -result = [arguments = 4, eval = 5] = value; - -assert.sameValue(result, value); +//- setup +var argument, eval; +//- elems +[arguments = 4, eval = 5] +//- vals +[] +//- body assert.sameValue(arguments, 4); assert.sameValue(eval, 5); diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-simple-strict.js b/src/dstr-assignment/array-elem-init-simple-strict.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-elem-target-simple-strict.js rename to src/dstr-assignment/array-elem-init-simple-strict.case index 2d0659bf428e6dc8474aaac1b33ae5dc173993c6..7158a328b8396a24e1fe9ac4fd796ae1238907d1 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-simple-strict.js +++ b/src/dstr-assignment/array-elem-init-simple-strict.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is false. +template: syntax es6id: 12.14.5.1 flags: [onlyStrict] negative: SyntaxError ---*/ -([arguments] = []); +//- elems +[arguments] +//- values +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-yield-expr.js b/src/dstr-assignment/array-elem-init-yield-expr.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-elem-init-yield-expr.js rename to src/dstr-assignment/array-elem-init-yield-expr.case index 8f4a5d8b2492f3c6a9552702715401c9bfb409e8..6aa3a97ed7615942201adbb1ed050af589ae838f 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-yield-expr.js +++ b/src/dstr-assignment/array-elem-init-yield-expr.case @@ -2,31 +2,34 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the Initializer of an AssignmentElement within a generator function body, it behaves as a YieldExpression. +template: default es6id: 12.14.5.4 features: [generators] ---*/ +//- setup var value = []; -var assignmentResult, iterationResult, iter, x; - +var iterationResult, iter, x; iter = (function*() { - assignmentResult = [ x = yield ] = value; +//- elems +[ x = yield ] +//- vals +[] +//- teardown })(); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(86); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 86); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-invalid.js b/src/dstr-assignment/array-elem-init-yield-ident-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-invalid.js rename to src/dstr-assignment/array-elem-init-yield-ident-invalid.case index 429eb26b89fb0e4fb34de374fa9d3cf6af3f618d..c67ee2c344738aba8f1735f364ca582647678faa 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-invalid.js +++ b/src/dstr-assignment/array-elem-init-yield-ident-invalid.case @@ -2,13 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the Initializer of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. +template: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -[ x = yield ] = []; +//- elems +[ x = yield ] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-valid.js b/src/dstr-assignment/array-elem-init-yield-ident-valid.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-valid.js rename to src/dstr-assignment/array-elem-init-yield-ident-valid.case index 3d8d87cc57b16259ced4478516ec1b69bdec327c..05b7baac638eadaeca1ca40d0de8ae389205d7cf 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-yield-ident-valid.js +++ b/src/dstr-assignment/array-elem-init-yield-ident-valid.case @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the Initializer of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. +template: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = []; +//- setup var yield = 4; -var result, x; - -result = [ x = yield ] = value; - -assert.sameValue(result, value); +var x; +//- elems +[ x = yield ] +//- vals +[] +//- body assert.sameValue(x, 4); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-get-err.js b/src/dstr-assignment/array-elem-iter-get-err.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-iter-get-err.js rename to src/dstr-assignment/array-elem-iter-get-err.case index 2f545842fdec310241fe1ea53082a1052d024cd4..ed4a51ffa1dec58fb4149e8c8ac60601cb0ff7af 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-get-err.js +++ b/src/dstr-assignment/array-elem-iter-get-err.case @@ -1,23 +1,27 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from GetIterator +desc: Abrupt completion returned from GetIterator info: | ArrayAssignmentPattern : [ AssignmentElementList ] 1. Let iterator be GetIterator(value). 2. ReturnIfAbrupt(iterator). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; iterable[Symbol.iterator] = function() { throw new Test262Error(); }; -var x; - -assert.throws(Test262Error, function() { - [ x ] = iterable; -}); +var _; +//- error +Test262Error +//- elems +[ _ ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-err.js b/src/dstr-assignment/array-elem-iter-nrml-close-err.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-err.js rename to src/dstr-assignment/array-elem-iter-nrml-close-err.case index 414495122ca13bd92fec79be6f486c5c0f42ad20..197b79a77d48fb43da80fd32e1668623a51cd664 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-err.js +++ b/src/dstr-assignment/array-elem-iter-nrml-close-err.case @@ -1,20 +1,22 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from IteratorClose +desc: Abrupt completion returned from IteratorClose info: | ArrayAssignmentPattern : [ AssignmentElementList ] [...] 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; -var x; +var _; var iterable = {}; var iterator = { next: function() { @@ -31,10 +33,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x ] = iterable; -}); - +//- elems +[ _ ] +//- vals +iterable +//- error +Test262Error +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-null.js b/src/dstr-assignment/array-elem-iter-nrml-close-null.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-null.js rename to src/dstr-assignment/array-elem-iter-nrml-close-null.case index 67e3ead4d0d579817c4c7009c21ca3f307b20976..37314b7c17a8ca23386e7086a9889b22998c0a0a 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-null.js +++ b/src/dstr-assignment/array-elem-iter-nrml-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : [ AssignmentElementList ] @@ -20,11 +20,13 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ -var x; +//- setup +var _; var iterable = {}; var nextCount = 0; var iterator = { @@ -41,7 +43,9 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(TypeError, function() { - [ x ] = iterable; -}); +//- elems +[ _ ] +//- vals +iterable +//- error +TypeError diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-skip.js b/src/dstr-assignment/array-elem-iter-nrml-close-skip.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-skip.js rename to src/dstr-assignment/array-elem-iter-nrml-close-skip.case index c3b2087e8b0b2c313456741f8b62b2c9ca1028a5..5ae291334540f0bb1de2b67518d66b7aa0f0dbc0 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close-skip.js +++ b/src/dstr-assignment/array-elem-iter-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when assignment evaluation has exhausted the iterator info: | @@ -11,13 +11,15 @@ info: | 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). 6. Return result. features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; -var x; +var _; var iterable = {}; var iterator = { next: function() { @@ -32,8 +34,10 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x ] = iterable; - +//- elems +[ _ ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close.js b/src/dstr-assignment/array-elem-iter-nrml-close.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close.js rename to src/dstr-assignment/array-elem-iter-nrml-close.case index 80f9902b03a7db0749619d490a66a54dab52f741..f66f0ccda0e3adbfaf0b6d56284bd65ab90e2546 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-nrml-close.js +++ b/src/dstr-assignment/array-elem-iter-nrml-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when assignment evaluation has not exhausted the iterator info: | @@ -18,15 +18,17 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; var args = null; -var x; +var _; var iterable = {}; var iterator = { next: function() { @@ -45,9 +47,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x ] = iterable; - +//- elems +[ _ ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-err.js b/src/dstr-assignment/array-elem-iter-rtrn-close-err.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-err.js rename to src/dstr-assignment/array-elem-iter-rtrn-close-err.case index 4b3b2a36ae75b0623dd3c6178be83806f413777f..3742cf1509b528253209e33944ab69a3fd761200 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-err.js +++ b/src/dstr-assignment/array-elem-iter-rtrn-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "return" completion info: | @@ -19,10 +19,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; var iterable = {}; @@ -38,8 +40,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ {}[yield] ] = iterable; - unreachable += 1; +//- elems +[ {}[ yield ] ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown } iter = g(); iter.next(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-null.js b/src/dstr-assignment/array-elem-iter-rtrn-close-null.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-null.js rename to src/dstr-assignment/array-elem-iter-rtrn-close-null.case index 4e95868e8c4bc681a4685c2c81cd0a21a79d9aac..817ca7b6bb0837fa05240cc2423eb1c460bd037d 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close-null.js +++ b/src/dstr-assignment/array-elem-iter-rtrn-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : [ AssignmentElementList ] @@ -20,10 +20,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var iterator = { return: function() { @@ -35,8 +37,13 @@ iterable[Symbol.iterator] = function() { return iterator; }; function* g() { - [ {}[yield] ] = iterable; +//- elems +[ {}[yield] ] +//- vals +iterable +//- body unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close.js b/src/dstr-assignment/array-elem-iter-rtrn-close.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close.js rename to src/dstr-assignment/array-elem-iter-rtrn-close.case index 2d9380de2053f86b0d8a1c7a293efc07792adde3..7f1c482fe5448c7b39d2e3e556aa84b8bd2b990c 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-rtrn-close.js +++ b/src/dstr-assignment/array-elem-iter-rtrn-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "return" completion info: | @@ -19,10 +19,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; var thisValue = null; @@ -42,8 +44,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ {}[yield] ] = iterable; - unreachable += 1; +//- elems +[ {}[yield] ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown } iter = g(); iter.next(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-err.js b/src/dstr-assignment/array-elem-iter-thrw-close-err.case similarity index 89% rename from test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-err.js rename to src/dstr-assignment/array-elem-iter-thrw-close-err.case index d92f9a4359970bcd815710d76916b8558c525421..04c4da8cc1ce4885d4fe26702bf733f1e7a33324 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-err.js +++ b/src/dstr-assignment/array-elem-iter-thrw-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "throw" completion info: | @@ -12,10 +12,12 @@ info: | result). 6. Return result. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; function ReturnError() {} @@ -38,10 +40,12 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ {}[thrower()] ] = iterable; -}); - +//- error +Test262Error +//- elems +[ {}[thrower()] ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-skip.js b/src/dstr-assignment/array-elem-iter-thrw-close-skip.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-skip.js rename to src/dstr-assignment/array-elem-iter-thrw-close-skip.case index fc27f58e38d58458f6fcd7b6d5a29bcd46fa2247..7ac68788d25fbef4f46afeaad052a0fda14b55d7 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close-skip.js +++ b/src/dstr-assignment/array-elem-iter-thrw-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when iteration produces an abrupt completion info: | ArrayAssignmentPattern : [ AssignmentElementList ] @@ -11,10 +11,12 @@ info: | result). 6. Return result. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -30,11 +32,13 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; -var x; - -assert.throws(Test262Error, function() { - [ x ] = iterable; -}); - +var _; +//- error +Test262Error +//- elems +[ x ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close.js b/src/dstr-assignment/array-elem-iter-thrw-close.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close.js rename to src/dstr-assignment/array-elem-iter-thrw-close.case index 4474c432fc36ffd9573af3dc95cf20fc5af8a122..17129f09dbb5f544a3f683c42d5ed45bef650193 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-iter-thrw-close.js +++ b/src/dstr-assignment/array-elem-iter-thrw-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "throw" completion info: | @@ -18,10 +18,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -44,11 +46,13 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ {}[thrower()] ] = iterable; -}); - +//- error +Test262Error +//- elems +[ {}[thrower()] ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-invalid.js b/src/dstr-assignment/array-elem-nested-array-invalid.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-invalid.js rename to src/dstr-assignment/array-elem-nested-array-invalid.case index 1b0a2471edcf8a186ab78adad7bb1c94f1affa74..9cceb9f06f7ccddb25adcb2324e3ac55512a1ea3 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-invalid.js +++ b/src/dstr-assignment/array-elem-nested-array-invalid.case @@ -2,15 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.1 negative: SyntaxError ---*/ -var x, y; - -[...[(x, y)]] = [[]]; +//- elems +[[(x, y)]] +//- vals +[[]] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-null.js b/src/dstr-assignment/array-elem-nested-array-null.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-null.js rename to src/dstr-assignment/array-elem-nested-array-null.case index 98362d693f4a6f40f66e2eb3e09b00d2e8eb946f..5910534f2b09e0b118c82e07d6725a8896739fd6 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-null.js +++ b/src/dstr-assignment/array-elem-nested-array-null.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is `null`, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ -var x; - -assert.throws(TypeError, function() { - [[ x ]] = [null]; -}); +//- setup +var _; +//- error +TypeError +//- elems +[[ _ ]] +//- vals +[null] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-hole.js b/src/dstr-assignment/array-elem-nested-array-undefined-hole.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-hole.js rename to src/dstr-assignment/array-elem-nested-array-undefined-hole.case index 047e093c2ea8f03db409595d6e5e277e5920e087..f0561b8be7a61fed272f61227ba5924acdf3e154 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-hole.js +++ b/src/dstr-assignment/array-elem-nested-array-undefined-hole.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is a "hole", a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ -var x; - -assert.throws(TypeError, function() { - [[ x ]] = [ , ]; -}); +//- setup +var _; +//- error +TypeError +//- elems +[[ _ ]] +//- vals +[ , ] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-own.js b/src/dstr-assignment/array-elem-nested-array-undefined-own.case similarity index 74% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-own.js rename to src/dstr-assignment/array-elem-nested-array-undefined-own.case index c9b72457c821667c5e06cbbd870652eeb76ab84a..1972f02ee86a12ad68472618d2b97a62b2ee763e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined-own.js +++ b/src/dstr-assignment/array-elem-nested-array-undefined-own.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is `undefined`, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ -var x; - -assert.throws(TypeError, function() { - [[ x ]] = [undefined]; -}); +//- setup +var _; +//- error +TypeError +//- elems +[[ x ]] +//- vals +[undefined] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined.js b/src/dstr-assignment/array-elem-nested-array-undefined.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined.js rename to src/dstr-assignment/array-elem-nested-array-undefined.case index d280bf26974586638302863879f852eb875a161d..6b07a4f03b4f271723b773c55fc95f4a0acf2574 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-undefined.js +++ b/src/dstr-assignment/array-elem-nested-array-undefined.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and no value is defined, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ -var x; - -assert.throws(TypeError, function() { - [[ x ]] = []; -}); +//- setup +var _; +//- error +TypeError +//- elems +[[ x ]] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-expr.js b/src/dstr-assignment/array-elem-nested-array-yield-expr.case similarity index 80% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-expr.js rename to src/dstr-assignment/array-elem-nested-array-yield-expr.case index 5128f3774e12c748c62d2035fe0bc9b01bab212d..bd5d94ffab58e730e22176986e9ead9f22e86f5a 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-expr.js +++ b/src/dstr-assignment/array-elem-nested-array-yield-expr.case @@ -2,32 +2,36 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.3 features: [generators] ---*/ +//- setup var value = [[22]]; var x = {}; -var assignmentResult, iterationResult, iter; +var iterationResult, iter; iter = (function*() { - assignmentResult = [[x[yield]]] = value; +//- elems +[[x[yield]]] +//- vals +value +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); iterationResult = iter.next('prop'); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop, 22); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-invalid.js b/src/dstr-assignment/array-elem-nested-array-yield-ident-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-invalid.js rename to src/dstr-assignment/array-elem-nested-array-yield-ident-invalid.case index bba32536e3334239c2b428b536510d16e73d6769..006428417bdcf8ec3ee1b5cb3af2601eb9205cd8 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-invalid.js +++ b/src/dstr-assignment/array-elem-nested-array-yield-ident-invalid.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. +template: syntax es6id: 12.14.5.3 flags: [onlyStrict] negative: SyntaxError ---*/ -[[x[yield]]] = value; +//- elems +[[x[yield]]] +//- vals +[[]] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-valid.js b/src/dstr-assignment/array-elem-nested-array-yield-ident-valid.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-valid.js rename to src/dstr-assignment/array-elem-nested-array-yield-ident-valid.case index 01ea78ebaef8e8d2dfea8585560e578b0ebd40f7..c1bcd3c67b9213207850650f83e5988cbe74c2f0 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-yield-ident-valid.js +++ b/src/dstr-assignment/array-elem-nested-array-yield-ident-valid.case @@ -2,20 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = [[22]]; +//- setup var yield = 'prop'; var x = {}; -var result; - -result = [[x[yield]]] = value; - -assert.sameValue(result, value); +//- elems +[[x[yield]]] +//- vals +[[22]] +//- body assert.sameValue(x.prop, 22); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array.js b/src/dstr-assignment/array-elem-nested-array.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array.js rename to src/dstr-assignment/array-elem-nested-array.case index 0fb07e27b17a85e43e5e05c0d306cce25373f86d..7c5902abfc6a4bb5affffb3d353aa5ea06d6679e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array.js +++ b/src/dstr-assignment/array-elem-nested-array.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [[1]]; -var x, result; - -result = [[x]] = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +[[x]] +//- vals +[[1]] +//- body assert.sameValue(x, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-array-invalid.js b/src/dstr-assignment/array-elem-nested-obj-invalid.case similarity index 87% rename from test/language/expressions/assignment/destructuring/array-elem-nested-array-invalid.js rename to src/dstr-assignment/array-elem-nested-obj-invalid.case index 8c5e1831903c59f7f3e8a9437a0de0e3bf005278..3bf2ec0f31c39cf9275f628afa7f2e4d6e1c7956 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-array-invalid.js +++ b/src/dstr-assignment/array-elem-nested-obj-invalid.case @@ -2,15 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.1 negative: SyntaxError ---*/ -var x, y; - -[[(x, y)]] = [[]]; +//- elems +[{ get x() {} }] +//- vals +[{}] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-null.js b/src/dstr-assignment/array-elem-nested-obj-null.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-null.js rename to src/dstr-assignment/array-elem-nested-obj-null.case index 5485fde7363a9ca7180a32a9f86cd219c6f53006..fb728438148f6d806f1f11803cac1fc0fae8947e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-null.js +++ b/src/dstr-assignment/array-elem-nested-obj-null.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is `null`, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - [{ x }] = [null]; -}); +//- error +TypeError +//- elems +[{ x }] +//- vals +[null] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-hole.js b/src/dstr-assignment/array-elem-nested-obj-undefined-hole.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-hole.js rename to src/dstr-assignment/array-elem-nested-obj-undefined-hole.case index 3984ff7a31b0ed6a0665814d04688701a0d3e014..dc463ec8156f43766d830e7f49a3eb752e1ce348 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-hole.js +++ b/src/dstr-assignment/array-elem-nested-obj-undefined-hole.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is a "hole", a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - [{ x }] = [ , ]; -}); +//- error +TypeError +//- elems +[{ x }] +//- vals +[ , ] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-own.js b/src/dstr-assignment/array-elem-nested-obj-undefined-own.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-own.js rename to src/dstr-assignment/array-elem-nested-obj-undefined-own.case index 39614e4bdfeb44dec0f67c5fe5451ca840b9d415..179ae08e89f0e41128483177f4c9b4aa9148930b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined-own.js +++ b/src/dstr-assignment/array-elem-nested-obj-undefined-own.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is `undefined`, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - [{ x }] = [undefined]; -}); +//- error +TypeError +//- elems +[{ x }] +//- vals +[undefined] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined.js b/src/dstr-assignment/array-elem-nested-obj-undefined.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined.js rename to src/dstr-assignment/array-elem-nested-obj-undefined.case index 8326c339aae7f97d5cff4fb46731153083129c46..016d0590be5362b0d025179dd13ed6d9d0c23256 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-undefined.js +++ b/src/dstr-assignment/array-elem-nested-obj-undefined.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and no value is defined, a TypeError should be thrown. +template: error es6id: 12.14.5.3 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - [{ x }] = []; -}); +//- error +TypeError +//- elems +[{ x }] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-expr.js b/src/dstr-assignment/array-elem-nested-obj-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-expr.js rename to src/dstr-assignment/array-elem-nested-obj-yield-expr.case index 3d72841db92b7ecb33487886ae30456669cdc157..4622b03b726ec2c396a63da791dd59795dc12a83 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-expr.js +++ b/src/dstr-assignment/array-elem-nested-obj-yield-expr.case @@ -2,31 +2,34 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it behaves as a YieldExpression. +template: default es6id: 12.14.5.3 features: [generators] ---*/ -var value = [{}]; -var assignmentResult, iterationResult, iter, x; +//- setup +var iterationResult, iter, x; iter = (function*() { - assignmentResult = [{ x = yield }] = value; +//- elems +[{ x = yield }] +//- vals +[{}] +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(4); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 4); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-invalid.js b/src/dstr-assignment/array-elem-nested-obj-yield-ident-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-invalid.js rename to src/dstr-assignment/array-elem-nested-obj-yield-ident-invalid.case index 39a024f39303df2521cd74167425a5e10cafc6ea..ce9db76419f00e30a6b29eee709bace83ff8112b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-invalid.js +++ b/src/dstr-assignment/array-elem-nested-obj-yield-ident-invalid.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.3 flags: [onlyStrict] negative: SyntaxError ---*/ -[{ x = yield }] = [{}]; +//- elems +[{ x = yield }] +//- vals +[{}] diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-valid.js b/src/dstr-assignment/array-elem-nested-obj-yield-ident-valid.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-valid.js rename to src/dstr-assignment/array-elem-nested-obj-yield-ident-valid.case index 6837411f45079ae953490aa7826697234258ecd3..d0caa64d4d394b03ddafa1a2b505c94a064e4059 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-yield-ident-valid.js +++ b/src/dstr-assignment/array-elem-nested-obj-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as an IdentifierReference. +template: default es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = [{}]; +//- setup var yield = 2; -var result, x; - -result = [{ x = yield }] = value; - -assert.sameValue(result, value); +var x; +//- elems +[{ x = yield }] +//- vals +[{}] +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj.js b/src/dstr-assignment/array-elem-nested-obj.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj.js rename to src/dstr-assignment/array-elem-nested-obj.case index 94778a614e264eb2af7daf43c0ce6d403f350075..bcb9877600bdc032d02dcf0a9ae02b0a345f05a6 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj.js +++ b/src/dstr-assignment/array-elem-nested-obj.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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.3 ---*/ -var value = [{ x: 2 }]; -var result, x; - -result = [{ x }] = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +[{ x }] +//- vals +[{ x: 2 }] +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-const.js b/src/dstr-assignment/array-elem-put-const.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-elem-put-const.js rename to src/dstr-assignment/array-elem-put-const.case index 44f8985b571e319dcdc1f4abafd915ae4896effa..cbd2841782181c621797d4e2959e14295e88fc22 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-const.js +++ b/src/dstr-assignment/array-elem-put-const.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `const` semantics. +template: error es6id: 12.14.5.3 features: [const] ---*/ +//- setup const c = null; - -assert.throws(TypeError, function() { - [ c ] = [1]; -}); +//- error +TypeError +//- elems +[ c ] +//- vals +[1] diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-let.js b/src/dstr-assignment/array-elem-put-let.case similarity index 71% rename from test/language/expressions/assignment/destructuring/array-rest-put-let.js rename to src/dstr-assignment/array-elem-put-let.case index a1507234619bc720316b998e7f479923f7c42b3b..54dbfb4c4ffcdde2f27398f5ef63430cfbfe26ca 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-let.js +++ b/src/dstr-assignment/array-elem-put-let.case @@ -2,13 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `let` semantics. +template: error es6id: 12.14.5.3 features: [let] ---*/ -assert.throws(ReferenceError, function() { - [ ...x ] = []; - let x; -}); +//- elems +[ x ] +//- vals +[] +//- error +ReferenceError +//- teardown +let x; diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-no-get.js b/src/dstr-assignment/array-elem-put-prop-ref-no-get.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-no-get.js rename to src/dstr-assignment/array-elem-put-prop-ref-no-get.case index 4bd7a8a8adc5e06bf9b9811a438acc880bc99f0d..6763ca4fcf14eb312ab5538101e5dc31f1984a17 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-no-get.js +++ b/src/dstr-assignment/array-elem-put-prop-ref-no-get.case @@ -2,14 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. +template: default es6id: 12.14.5.3 ---*/ -var value = [23]; -var x, setValue, result; +//- setup +var x, setValue; x = { get y() { $ERROR('The property should not be accessed.'); @@ -18,8 +19,9 @@ x = { setValue = val; } }; - -result = [x.y] = value; - -assert.sameValue(result, value); +//- elems +[x.y] +//- vals +[23] +//- body assert.sameValue(setValue, 23); diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-user-err.js b/src/dstr-assignment/array-elem-put-prop-ref-user-err.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-user-err.js rename to src/dstr-assignment/array-elem-put-prop-ref-user-err.case index 00c43f26562f532418d5a7f757cfac3fc70cbb89..4f4792b43fe8e97cbb7bb222d7f3a4f6ee91185b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref-user-err.js +++ b/src/dstr-assignment/array-elem-put-prop-ref-user-err.case @@ -2,19 +2,22 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Any error raised as a result of setting the value should be forwarded to the runtime. +template: error es6id: 12.14.5.3 ---*/ -var value = [23]; +//- setup var x = { set y(val) { throw new Test262Error(); } }; - -assert.throws(Test262Error, function() { - [x.y] = value; -}); +//- error +Test262Error +//- elems +[x.y] +//- vals +[23] diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref.js b/src/dstr-assignment/array-elem-put-prop-ref.case similarity index 74% rename from test/language/expressions/assignment/destructuring/array-elem-put-prop-ref.js rename to src/dstr-assignment/array-elem-put-prop-ref.case index b0b419c7bd04e647741c759da436b9ac9f5338f1..983bcfc57c986e9e3c2da6368d0abab917c6a379 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-prop-ref.js +++ b/src/dstr-assignment/array-elem-put-prop-ref.case @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. +template: default es6id: 12.14.5.3 ---*/ -var value = [4]; +//- setup var x = {}; -var result; - -result = [x.y] = value; - -assert.sameValue(result, value); +//- elems +[x.y] +//- vals +[4] +//- body assert.sameValue(x.y, 4); diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-no-strict.js b/src/dstr-assignment/array-elem-put-unresolvable-no-strict.case similarity index 81% rename from test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-no-strict.js rename to src/dstr-assignment/array-elem-put-unresolvable-no-strict.case index 41fc5d4153e61213bd6640d9f0e093d417f97422..fe7be7c70e329da8e0def2ab85dbb1900990e078 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-no-strict.js +++ b/src/dstr-assignment/array-elem-put-unresolvable-no-strict.case @@ -2,15 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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.3 flags: [noStrict] ---*/ +//- setup { - [ unresolvable ] = []; +//- elems +[ unresolvable ] +//- vals +[] +//- teardown } assert.sameValue(unresolvable, undefined); diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-strict.js b/src/dstr-assignment/array-elem-put-unresolvable-strict.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-strict.js rename to src/dstr-assignment/array-elem-put-unresolvable-strict.case index b06bac9c559cf9b0cd62e96c249d13ad87862c3d..98dbacc75ffeeddc1a9146467a61fe327a518ca2 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-unresolvable-strict.js +++ b/src/dstr-assignment/array-elem-put-unresolvable-strict.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. +template: error es6id: 12.14.5.3 flags: [onlyStrict] ---*/ -assert.throws(ReferenceError, function() { - [ unresolvable ] = []; -}); +//- error +ReferenceError +//- elems +[ unresolvable ] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-identifier.js b/src/dstr-assignment/array-elem-target-identifier.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-elem-target-identifier.js rename to src/dstr-assignment/array-elem-target-identifier.case index 17e1e403d935bdd7a465389175e99c1627b343c1..c45bbc8ac6a9ce5caa6418a10be47815684005bd 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-identifier.js +++ b/src/dstr-assignment/array-elem-target-identifier.case @@ -2,20 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. +template: default es6id: 12.14.5.3 ---*/ -var value = [1, 2, 3]; +//- setup var x, y, z; -var result; - -result = [x, y, z] = value; - -assert.sameValue(result, value); +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body assert.sameValue(x, 1); assert.sameValue(y, 2); assert.sameValue(z, 3); diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-simple-no-strict.js b/src/dstr-assignment/array-elem-target-simple-no-strict.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-elem-target-simple-no-strict.js rename to src/dstr-assignment/array-elem-target-simple-no-strict.case index 93421ae7efb355a513ff7b6791ad863cd1a4ed70..6c442211b1ab54fa1f859f6b8cb2ab645d085f26 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-simple-no-strict.js +++ b/src/dstr-assignment/array-elem-target-simple-no-strict.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. +template: default es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = [2, 3]; -var result, argument, eval; - -result = [arguments, eval] = value; - -assert.sameValue(result, value); +//- setup +var argument, eval; +//- elems +[arguments, eval] +//- vals +[2, 3] +//- body assert.sameValue(arguments, 2); assert.sameValue(eval, 3); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-simple-strict.js b/src/dstr-assignment/array-elem-target-simple-strict.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-elem-init-simple-strict.js rename to src/dstr-assignment/array-elem-target-simple-strict.case index 2d0659bf428e6dc8474aaac1b33ae5dc173993c6..b9a8adf7703359d7b61672dffe5ec4584becf393 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-init-simple-strict.js +++ b/src/dstr-assignment/array-elem-target-simple-strict.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is false. +template: syntax es6id: 12.14.5.1 flags: [onlyStrict] negative: SyntaxError ---*/ -([arguments] = []); +//- elems +[arguments] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-yield-expr.js b/src/dstr-assignment/array-elem-target-yield-expr.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-elem-target-yield-expr.js rename to src/dstr-assignment/array-elem-target-yield-expr.case index 6505a39694de37374b7f829f337099c04aeddd0f..316af932ba5316554e86b14f6202a5edf9be69f0 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-yield-expr.js +++ b/src/dstr-assignment/array-elem-target-yield-expr.case @@ -2,32 +2,36 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement within a generator function body, it behaves as a YieldExpression. +template: default es6id: 12.14.5.4 features: [generators] ---*/ +//- setup var value = [33]; var x = {}; -var assignmentResult, iterationResult, iter; +var iterationResult, iter; iter = (function*() { - assignmentResult = [ x[yield] ] = value; +//- elems +[ x[yield] ] +//- vals +[33] +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); iterationResult = iter.next('prop'); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop, 33); diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-yield-invalid.js b/src/dstr-assignment/array-elem-target-yield-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-elem-target-yield-invalid.js rename to src/dstr-assignment/array-elem-target-yield-invalid.case index f03f598683f323df547b69987a4e382b7146e7e0..0ff8247068ea9b0359e32b2bdc832fcf22dcfa2f 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-yield-invalid.js +++ b/src/dstr-assignment/array-elem-target-yield-invalid.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -[ x[yield] ] = []; +//- elems +[ x[yield] ] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-elem-target-yield-valid.js b/src/dstr-assignment/array-elem-target-yield-valid.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-elem-target-yield-valid.js rename to src/dstr-assignment/array-elem-target-yield-valid.case index 0363d1d3c6b856358c79687a033652bd0455a5a0..8b3263fabdf8b3e64e02a9611ec577d95626160e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-target-yield-valid.js +++ b/src/dstr-assignment/array-elem-target-yield-valid.case @@ -2,20 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. +template: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = [33]; +//- setup var yield = 'prop'; var x = {}; -var result; - -result = [ x[yield] ] = value; - -assert.sameValue(result, value); +//- elems +[ x[yield] ] +//- vals +[33] +//- body assert.sameValue(x.prop, 33); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-abpt.js b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-abpt.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-abpt.js rename to src/dstr-assignment/array-elem-trlg-iter-elision-iter-abpt.case index c4624b2c48109267299735651ae59bd4433c2421..999469551570d8c924733d2c791a12cde2305bec 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-abpt.js +++ b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-abpt.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned during evaluation of elision +desc: Abrupt completion returned during evaluation of elision info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -16,10 +16,12 @@ info: | IteratorClose(iterator, status). ii. Return Completion(status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -44,9 +46,12 @@ iterable[Symbol.iterator] = function() { return iterator; }; -assert.throws(Test262Error, function() { - [ x , , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 2); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-err.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-err.case index abb0aa22bbf9312399004ea8a9fb7f22b39cec69..554f0662f8e0a44912c63f54f470bec02439d84a 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from IteratorClose +desc: Abrupt completion returned from IteratorClose info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -16,10 +16,12 @@ info: | 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -40,10 +42,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x , , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 2); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-null.js b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-null.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-null.js rename to src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-null.case index edb875d5e6b1a6d685e17b6001eb38b4ebe36b6c..8b67b0f7b7746913713e08741130dcbcf68de103 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-null.js +++ b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : @@ -26,10 +26,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var x; var nextCount = 0; @@ -47,7 +49,9 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(TypeError, function() { - [ x , , ] = iterable; -}); +//- error +TypeError +//- elems +[ x , , ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-skip.js b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-skip.case similarity index 88% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-skip.js rename to src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-skip.case index e1ba46661f39ab4b9c774c73db393dc61ac525d3..537491d49a5d86021c7acfbcbee893f12491451c 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close-skip.js +++ b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: IteratorClose not invoked when elision exhausts the iterator +desc: IteratorClose not invoked when elision exhausts the iterator info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -17,10 +17,12 @@ info: | status). 9. Return Completion(status). features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -38,8 +40,10 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x , , ] = iterable; - +//- elems +[ x , , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 2); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close.js b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close.js rename to src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close.case index b7846bb1abe28ac06409a531d85f7b71f7659790..9c99e7d2b24d7a3efe512cbb549447d080394cb1 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-elision-iter-nrml-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: IteratorClose invoked when elision does not exhaust the iterator +desc: IteratorClose invoked when elision does not exhaust the iterator info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -22,10 +22,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -50,9 +52,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x , , ] = iterable; - +//- elems +[ x , , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 2); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-get-err.js b/src/dstr-assignment/array-elem-trlg-iter-get-err.case similarity index 80% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-get-err.js rename to src/dstr-assignment/array-elem-trlg-iter-get-err.case index 7a3e3a9a3a4c2e7286cb4b551295e526fbd47f1e..b47c3ae4bc999458e1bbb0aa1db072368cee1b4b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-get-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-get-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from GetIterator +desc: Abrupt completion returned from GetIterator info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -9,16 +9,20 @@ info: | 1. Let iterator be GetIterator(value). 2. ReturnIfAbrupt(iterator). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; iterable[Symbol.iterator] = function() { throw new Test262Error(); }; var x; - -assert.throws(Test262Error, function() { - [ x , ] = iterable; -}); +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-err.case similarity index 89% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-err.case index 491d91e86c2ef75a466d2df23452bec6f787d62f..c432ef033435a7685c828da6e99d041c8901123c 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from IteratorClose +desc: Abrupt completion returned from IteratorClose info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -16,10 +16,12 @@ info: | status). b. Return Completion(status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -40,10 +42,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-null.js b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-null.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-null.js rename to src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-null.case index daa2b227b3713b89f710e999a26bf43407994a91..2f2bf8995b34befe502db1eabbd220eceb0d5b24 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-null.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : @@ -26,10 +26,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var x; var nextCount = 0; @@ -47,7 +49,9 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(TypeError, function() { - [ x , ] = iterable; -}); +//- error +TypeError +//- elems +[ x , ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-skip.js b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-skip.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-skip.js rename to src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-skip.case index a7b0f41c068ea1115ccc6c5f240546a8691f9628..6ecaf2ebc1c6c4dee09c233b5fe2fdb2d2e1bd9a 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close-skip.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not invoked when evaluation of AssignmentElementList exhausts the iterator info: | @@ -18,10 +18,12 @@ info: | status). b. Return Completion(status). features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -41,8 +43,10 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x , ] = iterable; - +//- elems +[ x , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close.js b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close.case similarity index 95% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close.js rename to src/dstr-assignment/array-elem-trlg-iter-list-nrml-close.case index 76582ec71b60c14b7951fc15ea857dfd34543bbd..519f63baa0668ccdcbe285b26801b24779795f96 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-nrml-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-nrml-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is invoked when evaluation of AssignmentElementList completes without exhausting the iterator info: | @@ -24,10 +24,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -51,9 +53,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x , ] = iterable; - +//- elems +[ x , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-err.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-err.case index 7591e15c5e22539fb0e6455ba12df2865a2cee45..628e827e4b7c9f4d58c0042bd7bf627f21aaf179 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is invoked when evaluation of AssignmentElementList returns a "return" completion and the iterator has not been marked as "done" info: | @@ -24,10 +24,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; var iterable = {}; @@ -44,8 +46,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ {}[yield] , ] = iterable; - unreachable += 1; +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body +unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-null.js b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-null.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-null.js rename to src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-null.case index c635b1b1304696f45ffb1d198501ee8990a554ed..8a807a3156762e89eda1446e0f8790b062bbd572 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close-null.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : @@ -26,10 +26,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var iterator = { return: function() { @@ -42,7 +44,11 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ {}[yield] , ] = iterable; +//- elems + [ {}[yield] , ] +//- vals +iterable +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close.js b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close.case similarity index 95% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close.js rename to src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close.case index 076dfeaccaadd012318668dce6a97e5160458b68..c7c10a93cb1962e7a61790b95f33b0162acb12b4 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-rtrn-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-rtrn-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is invoked when evaluation of AssignmentElementList returns a "return" completion and the iterator has not been marked as "done" info: | @@ -25,10 +25,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; var thisValue = null; @@ -49,8 +51,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ {}[yield] , ] = iterable; +//- elems +[ {}[yield] , ] +//- vals +iterable +//- body unreachable += 1; +//- teardown }; iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-err.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-err.case index 6580d3f941ff504d1d4402c97bc36a95b46db845..683b386b9d35f9a151ea85c3fcab684ddab82cb0 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is invoked when evaluation of AssignmentElementList returns a "throw" completion and the iterator has not been marked as "done" info: | @@ -23,10 +23,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -50,9 +52,13 @@ iterable[Symbol.iterator] = function() { return iterator; }; -assert.throws(Test262Error, function() { - [ {}[thrower()] , ] = iterable; -}); +//- error +Test262Error +//- elems +[ {}[thrower()] , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-skip.js b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-skip.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-skip.js rename to src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-skip.case index f07335161db882dc2d806908509e68ad1d5fa780..28d98902f7c4d8f3aafdfb4e55aaa77a2576fdf2 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close-skip.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not invoked when evaluation of AssignmentElementList returns an abrupt completion and the iterator has been marked as "done" info: | @@ -18,10 +18,12 @@ info: | status). b. Return Completion(status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -41,10 +43,12 @@ iterable[Symbol.iterator] = function() { return iterator; }; var x; - -assert.throws(Test262Error, function() { - [ x , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close.js b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close.js rename to src/dstr-assignment/array-elem-trlg-iter-list-thrw-close.case index d0b18b6d9df53a352da7403a64974d8f4f714143..b55284f19c91b536c23f16228f7553e54ecaa7eb 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-list-thrw-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-list-thrw-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is invoked when evaluation of AssignmentElementList returns a "throw" completion and the iterator has not been marked as "done" info: | @@ -24,10 +24,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -50,11 +52,13 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ {}[thrower()] , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ {}[thrower()] , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-nrml-close-skip.js b/src/dstr-assignment/array-elem-trlg-iter-rest-nrml-close-skip.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-nrml-close-skip.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-nrml-close-skip.case index 4f4cf16281dad1038844a9d010bfc5483a8ff633..54997742237698f69700ad1c8e4e1eaebc0eac6e 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-nrml-close-skip.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when rest element evaluation has exhausted the iterator info: | @@ -17,10 +17,12 @@ info: | status). 9. Return Completion(status). features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -37,9 +39,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ x , ...y ] = iterable; - +//- elems +[ x , ...y ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 2, 'nextCount'); assert.sameValue(returnCount, 0, 'returnCount'); assert.sameValue(x, 1, 'x'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-err.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-err.case index ce2189ac37f4aca2bd8915be761f36390499479d..e2635d742dcd7c08a410b3ef80427fdc3b93e53b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when AssignmentRestEvaluation produces a "return" completion due to reference evaluation info: | @@ -24,10 +24,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var unreachable = 0; @@ -51,8 +53,13 @@ iterable[Symbol.iterator] = function() { return iterator; }; function* g() { - [ x , ...{}[yield] ] = iterable; +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- body unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-null.js b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-null.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-null.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-null.case index f25ec5b79aee23951408bc07c2acb3bbf3391344..d241f148013d124d7186d6d1e78a30e278617791 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close-null.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : @@ -23,10 +23,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var iterable = {}; var x; @@ -47,7 +49,11 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ x , ...{}[yield] ] = iterable; +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close.js b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close.case similarity index 95% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close.case index da1e805331884c3b21e9c41fda3c6fd35b8dd607..c573c53fae6f70cf89e3619481f57de5638eea38 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-rtrn-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-rtrn-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when AssignmentRestEvaluation produces a "return" completion due to reference evaluation info: | @@ -24,10 +24,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var unreachable = 0; @@ -55,8 +57,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [ x , ...{}[yield] ] = iterable; +//- elems +[ x , ...{}[yield] ] +//- vals +iterable +//- body unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-err.js b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-err.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-err.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-err.case index beea275ccca5e70d3b003376d8ba82d70925297c..79ae32edb1464248cafeadc0e8f2ca2519a41a0c 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-err.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when AssignmentRestEvaluation produces a "throw" completion due to reference evaluation info: | @@ -22,10 +22,12 @@ info: | [...] 7. If completion.[[type]] is throw, return Completion(completion) features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var x; @@ -51,10 +53,12 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x , ...{}[thrower()] ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , ...{}[thrower()] ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-skip.js b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-skip.case similarity index 87% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-skip.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-skip.case index 4619bc0738d1a2b359953bb12eddb9142390bdce..5d53e487176c72bddde7bcd06be9a029428f31f7 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close-skip.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned during iteration for rest element +desc: Abrupt completion returned during iteration for rest element info: | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ] @@ -15,10 +15,12 @@ info: | status). 9. Return Completion(status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -42,10 +44,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x , ...x ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , ...x ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 2); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close.js b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close.js rename to src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close.case index eefc3e146645dedafd4fcf2bee60b120685a37ef..1908579446b978cb9bf11482b9da8d352800d73b 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-trlg-iter-rest-thrw-close.js +++ b/src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when AssignmentRestEvaluation produces a "throw" completion due to reference evaluation info: | @@ -23,10 +23,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -52,11 +54,13 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ x , ...{}[thrower()] ] = iterable; -}); - +//- error +Test262Error +//- elems +[ x , ...{}[thrower()] ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-abpt.js b/src/dstr-assignment/array-elision-iter-abpt.case similarity index 89% rename from test/language/expressions/assignment/destructuring/array-elision-iter-abpt.js rename to src/dstr-assignment/array-elision-iter-abpt.case index 82d43234bc0cc15521ead2c8bb7bed3db55ee932..3ae10f4790285e25da6f1c709feea2433ff891af 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-abpt.js +++ b/src/dstr-assignment/array-elision-iter-abpt.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when iteration produces an abrupt completion info: | ArrayAssignmentPattern : [ Elision ] @@ -12,10 +12,12 @@ info: | result). [...] features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -31,10 +33,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-get-err.js b/src/dstr-assignment/array-elision-iter-get-err.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-elision-iter-get-err.js rename to src/dstr-assignment/array-elision-iter-get-err.case index 8900065f15b6a899aa038fe7e7d7fcd32cdb2447..d623ab6907dfb4d549a86782c2c549daec9e2527 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-get-err.js +++ b/src/dstr-assignment/array-elision-iter-get-err.case @@ -1,22 +1,26 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from GetIterator +desc: Abrupt completion returned from GetIterator info: | ArrayAssignmentPattern : [ Elision ] 1. Let iterator be GetIterator(value). 2. ReturnIfAbrupt(iterator). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; iterable[Symbol.iterator] = function() { throw new Test262Error(); }; - -assert.throws(Test262Error, function() { - [ , ] = iterable; -}); +//- error +Test262Error +//- elems +[ , ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-err.js b/src/dstr-assignment/array-elision-iter-nrml-close-err.case similarity index 90% rename from test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-err.js rename to src/dstr-assignment/array-elision-iter-nrml-close-err.case index ad5fb2da511b64a4ba90d40b2a8ce88fa0091f57..e6ea53ee72556e6e4fcaed2c4d6722c0a7f70e7b 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-err.js +++ b/src/dstr-assignment/array-elision-iter-nrml-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Abrupt completion returned from IteratorClose info: | ArrayAssignmentPattern : [ Elision ] @@ -12,10 +12,12 @@ info: | result). 6. Return result. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -34,10 +36,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [ , ] = iterable; -}); - +//- error +Test262Error +//- elems +[ , ] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-null.js b/src/dstr-assignment/array-elision-iter-nrml-close-null.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-null.js rename to src/dstr-assignment/array-elision-iter-nrml-close-null.case index 528c0eaf19a05859b17485256270d426233885f6..e91c29fcf52080102ca803c06c9d3df56d5eb61b 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-null.js +++ b/src/dstr-assignment/array-elision-iter-nrml-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : [ Elision ] @@ -21,10 +21,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var nextCount = 0; var iterator = { @@ -41,7 +43,9 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(TypeError, function() { - [ , ] = iterable; -}); +//- error +TypeError +//- elems +[ , ] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-skip.js b/src/dstr-assignment/array-elision-iter-nrml-close-skip.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-skip.js rename to src/dstr-assignment/array-elision-iter-nrml-close-skip.case index ecff8153389d691fb3b85cd34ccdef2bafdf849b..17d7c97baf8838abd091dbebb13a8f6e0f44fb66 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close-skip.js +++ b/src/dstr-assignment/array-elision-iter-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when iteration has exhausted the iterator info: | ArrayAssignmentPattern : [ Elision ] @@ -12,10 +12,12 @@ info: | result). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -32,8 +34,10 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ , ] = iterable; - +//- elems +[ , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close.js b/src/dstr-assignment/array-elision-iter-nrml-close.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close.js rename to src/dstr-assignment/array-elision-iter-nrml-close.case index eba1f3cef4177101b4b3333247cbb8d33ca80f64..71c75a2d562cd8d314883b39a228a8a13fcf4dbc 100644 --- a/test/language/expressions/assignment/destructuring/array-elision-iter-nrml-close.js +++ b/src/dstr-assignment/array-elision-iter-nrml-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when assignment evaluation has not exhausted the iterator info: | @@ -19,10 +19,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -45,9 +47,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ , ] = iterable; - +//- elems +[ , ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/src/dstr-assignment/array-elision-val-array.case b/src/dstr-assignment/array-elision-val-array.case new file mode 100644 index 0000000000000000000000000000000000000000..70895eeef6cf47af055d357563a8dc3ed7177f19 --- /dev/null +++ b/src/dstr-assignment/array-elision-val-array.case @@ -0,0 +1,13 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values +template: default +es6id: 12.14.5.2 +---*/ + +//- elems +[,] +//- vals +[] diff --git a/src/dstr-assignment/array-elision-val-bool.case b/src/dstr-assignment/array-elision-val-bool.case new file mode 100644 index 0000000000000000000000000000000000000000..e9cbc6dd09497c8d9fad37661ca96e218fee49f9 --- /dev/null +++ b/src/dstr-assignment/array-elision-val-bool.case @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values + and throws for boolean values. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[,] +//- vals +true diff --git a/src/dstr-assignment/array-elision-val-null.case b/src/dstr-assignment/array-elision-val-null.case new file mode 100644 index 0000000000000000000000000000000000000000..3f4b644468ce06019ba06345e57f370d55ab813f --- /dev/null +++ b/src/dstr-assignment/array-elision-val-null.case @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values + and throws for `null`. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[,] +//- vals +null diff --git a/src/dstr-assignment/array-elision-val-num.case b/src/dstr-assignment/array-elision-val-num.case new file mode 100644 index 0000000000000000000000000000000000000000..99f14215d27dfff4889c4b7bf64931615175732b --- /dev/null +++ b/src/dstr-assignment/array-elision-val-num.case @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values + and throws for number values. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[,] +//- vals +1 diff --git a/src/dstr-assignment/array-elision-val-string.case b/src/dstr-assignment/array-elision-val-string.case new file mode 100644 index 0000000000000000000000000000000000000000..4072011b8ce5ffcc77e0c5c6364dc4057ba9c430 --- /dev/null +++ b/src/dstr-assignment/array-elision-val-string.case @@ -0,0 +1,13 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values +template: default +es6id: 12.14.5.2 +---*/ + +//- elems +[,] +//- vals +'string literal' diff --git a/src/dstr-assignment/array-elision-val-symbol.case b/src/dstr-assignment/array-elision-val-symbol.case new file mode 100644 index 0000000000000000000000000000000000000000..7b80f19b82d90405a95813cbbd90debd37e6c4cd --- /dev/null +++ b/src/dstr-assignment/array-elision-val-symbol.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values + and throws for symbol values. +template: error +es6id: 12.14.5.2 +features: [Symbol] +---*/ + +//- setup +var s = Symbol(); +//- error +TypeError +//- elems +[,] +//- vals +s diff --git a/src/dstr-assignment/array-elision-val-undef.case b/src/dstr-assignment/array-elision-val-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..4c7bf69fc7f6acc02ee9810d7c660eaa15ad148e --- /dev/null +++ b/src/dstr-assignment/array-elision-val-undef.case @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + An ArrayAssignmentPattern containing only Elisions requires iterable values + and throws for `undefined`. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[,] +//- vals +undefined diff --git a/test/language/expressions/assignment/destructuring/array-empty-iter-close-err.js b/src/dstr-assignment/array-empty-iter-close-err.case similarity index 84% rename from test/language/expressions/assignment/destructuring/array-empty-iter-close-err.js rename to src/dstr-assignment/array-empty-iter-close-err.case index a7e1d225fde16658fb2a54a1512b8f3312176e78..8d33d030d1639c2b77bf5c423078e2f221964d15 100644 --- a/test/language/expressions/assignment/destructuring/array-empty-iter-close-err.js +++ b/src/dstr-assignment/array-empty-iter-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from IteratorClose +desc: Abrupt completion returned from IteratorClose info: | ArrayAssignmentPattern : [ ] @@ -9,10 +9,12 @@ info: | 2. ReturnIfAbrupt(iterator). 3. Return IteratorClose(iterator, NormalCompletion(empty)). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -29,10 +31,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [] = iterable; -}); - +//- error +Test262Error +//- elems +[] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-empty-iter-close-null.js b/src/dstr-assignment/array-empty-iter-close-null.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-empty-iter-close-null.js rename to src/dstr-assignment/array-empty-iter-close-null.case index 1ef76906be2dec057d14af5572744f4d6ea981f4..42cef194a3f2a8c33353d55d1e151b8c19e672a8 100644 --- a/test/language/expressions/assignment/destructuring/array-empty-iter-close-null.js +++ b/src/dstr-assignment/array-empty-iter-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : [ ] @@ -19,10 +19,12 @@ info: | 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var iterator = { next: function() { @@ -35,7 +37,9 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(TypeError, function() { - [] = iterable; -}); +//- error +TypeError +//- elems +[] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-empty-iter-close.js b/src/dstr-assignment/array-empty-iter-close.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-empty-iter-close.js rename to src/dstr-assignment/array-empty-iter-close.case index c9a70d9c9aba42612f42c0cd74af760164cca4df..abd0f57908d657af02dd74fa8ab35709ae25e02f 100644 --- a/test/language/expressions/assignment/destructuring/array-empty-iter-close.js +++ b/src/dstr-assignment/array-empty-iter-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Iterator is closed without iterating +desc: Iterator is closed without iterating info: | ArrayAssignmentPattern : [ ] @@ -15,10 +15,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -39,9 +41,11 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[] = iterable; - +//- elems +[] +//- vals +iterable +//- body assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-empty-iter-get-err.js b/src/dstr-assignment/array-empty-iter-get-err.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-empty-iter-get-err.js rename to src/dstr-assignment/array-empty-iter-get-err.case index efd5b21d4a4e4896adae9ec2f442392664e46ca1..2a66e18b82a26e268759908481738ea79fc29042 100644 --- a/test/language/expressions/assignment/destructuring/array-empty-iter-get-err.js +++ b/src/dstr-assignment/array-empty-iter-get-err.case @@ -1,22 +1,26 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from GetIterator +desc: Abrupt completion returned from GetIterator info: | ArrayAssignmentPattern : [ ] 1. Let iterator be GetIterator(value). 2. ReturnIfAbrupt(iterator). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; iterable[Symbol.iterator] = function() { throw new Test262Error(); }; - -assert.throws(Test262Error, function() { - [] = iterable; -}); +//- error +Test262Error +//- elems +[] +//- vals +iterable diff --git a/src/dstr-assignment/array-empty-val-array.case b/src/dstr-assignment/array-empty-val-array.case new file mode 100644 index 0000000000000000000000000000000000000000..5820b7175b9c0583d7ec75f5466e33f98a9b394b --- /dev/null +++ b/src/dstr-assignment/array-empty-val-array.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values. +template: default +es6id: 12.14.5.2 +---*/ + +//- elems +[] +//- vals +[] diff --git a/src/dstr-assignment/array-empty-val-bool.case b/src/dstr-assignment/array-empty-val-bool.case new file mode 100644 index 0000000000000000000000000000000000000000..327085e164cb7efb068b19939bd9c87aa8560178 --- /dev/null +++ b/src/dstr-assignment/array-empty-val-bool.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values and throws for boolean values +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[] +//- vals +true diff --git a/src/dstr-assignment/array-empty-val-null.case b/src/dstr-assignment/array-empty-val-null.case new file mode 100644 index 0000000000000000000000000000000000000000..d42b89aca6b80ce4e06f54e617516f40ffc4865f --- /dev/null +++ b/src/dstr-assignment/array-empty-val-null.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values and throws for `null`. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[] +//- vals +null diff --git a/src/dstr-assignment/array-empty-val-num.case b/src/dstr-assignment/array-empty-val-num.case new file mode 100644 index 0000000000000000000000000000000000000000..8adbc65262713dec684edf84825ea6e573e4b432 --- /dev/null +++ b/src/dstr-assignment/array-empty-val-num.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values and throws for number values. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[] +//- vals +1 diff --git a/src/dstr-assignment/array-empty-val-string.case b/src/dstr-assignment/array-empty-val-string.case new file mode 100644 index 0000000000000000000000000000000000000000..102c9c37aee7ed3082863bfef0f4be50cfeee00c --- /dev/null +++ b/src/dstr-assignment/array-empty-val-string.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values. +template: default +es6id: 12.14.5.2 +---*/ + +//- elems +[] +//- vals +'string literal' diff --git a/src/dstr-assignment/array-empty-val-symbol.case b/src/dstr-assignment/array-empty-val-symbol.case new file mode 100644 index 0000000000000000000000000000000000000000..723fc7eed54541d5f20c9a27c832726383d13fa3 --- /dev/null +++ b/src/dstr-assignment/array-empty-val-symbol.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values and throws for Symbol values. +template: error +es6id: 12.14.5.2 +---*/ + +//- setup +var s = Symbol(); +//- error +TypeError +//- elems +[] +//- vals +s diff --git a/src/dstr-assignment/array-empty-val-undef.case b/src/dstr-assignment/array-empty-val-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..b2af204310e59addd70e790bb05b75a297265c84 --- /dev/null +++ b/src/dstr-assignment/array-empty-val-undef.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + An ArrayAssignmentPattern without an AssignmentElementList requires + iterable values and throws for `undefined`. +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +[] +//- vals +undefined diff --git a/src/dstr-assignment/array-iteration.case b/src/dstr-assignment/array-iteration.case new file mode 100644 index 0000000000000000000000000000000000000000..be62fb27292ee6a81e76575f614281de60957198 --- /dev/null +++ b/src/dstr-assignment/array-iteration.case @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Value iteration only proceeds for the number of elements in the + ArrayAssignmentPattern. +template: default +es6id: 12.14.5.3 +features: [generators] +---*/ + +//- setup +var count = 0; +var g = function*() { + count += 1; + yield; + count += 1; + yield; + count += 1; +} +//- elems +[,,] +//- vals +g() +//- body +assert.sameValue(count, 2); diff --git a/test/language/expressions/assignment/destructuring/array-rest-after-element.js b/src/dstr-assignment/array-rest-after-element.case similarity index 82% rename from test/language/expressions/assignment/destructuring/array-rest-after-element.js rename to src/dstr-assignment/array-rest-after-element.case index 4bfbcb625550312d06932bfee359dae9ce53457a..bb80557b0853da3a36f61b6249e6d9ea419d2615 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-after-element.js +++ b/src/dstr-assignment/array-rest-after-element.case @@ -2,16 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > An AssignmentRestElement following an AssignmentElement consumes all remaining iterable values. +template: default es6id: 12.14.5.3 ---*/ +//- setup var x, y; - -[x, ...y] = [1, 2, 3]; - +//- elems +[x, ...y] +//- vals +[1, 2, 3] +//- body assert.sameValue(x, 1); assert.sameValue(y.length, 2); assert.sameValue(y[0], 2); diff --git a/test/language/expressions/assignment/destructuring/array-rest-after-elision.js b/src/dstr-assignment/array-rest-after-elision.case similarity index 81% rename from test/language/expressions/assignment/destructuring/array-rest-after-elision.js rename to src/dstr-assignment/array-rest-after-elision.case index 379683ed0f8efe81de84ea179113db1dcc8bded2..48d06d5e146afc1b09260f21e2f0b1c87ba41716 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-after-elision.js +++ b/src/dstr-assignment/array-rest-after-elision.case @@ -2,16 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > An AssignmentRestElement following an elision consumes all remaining iterable values. +template: default es6id: 12.14.5.3 ---*/ +//- setup var x; - -[, ...x] = [1, 2, 3]; - +//- elems +[, ...x] +//- vals +[1, 2, 3] +//- body assert.sameValue(x.length, 2); assert.sameValue(x[0], 2); assert.sameValue(x[1], 3); diff --git a/test/language/expressions/assignment/destructuring/array-rest-before-element.js b/src/dstr-assignment/array-rest-before-element.case similarity index 83% rename from test/language/expressions/assignment/destructuring/array-rest-before-element.js rename to src/dstr-assignment/array-rest-before-element.case index 8c53b9b655649ec76817322d47d4e81e747247a9..fda8d7721fb5b50b2703794cafd2124d0ff67a34 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-before-element.js +++ b/src/dstr-assignment/array-rest-before-element.case @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > An AssignmentElement may not follow an AssignmentRestElement in an AssignmentElementList. +template: syntax es6id: 12.14.5 negative: SyntaxError ---*/ -var x, y; - -[...x, y] = []; +//- elems +[...x, y] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-before-elision.js b/src/dstr-assignment/array-rest-before-elision.case similarity index 83% rename from test/language/expressions/assignment/destructuring/array-rest-before-elision.js rename to src/dstr-assignment/array-rest-before-elision.case index 6480747165c7fe7823b819fa59850d5041f847e3..501f9ac1e6890084a970dbd8d008a8d6ca5a876e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-before-elision.js +++ b/src/dstr-assignment/array-rest-before-elision.case @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > An elision may not follow an AssignmentRestElement in an AssignmentElementList. +template: syntax es6id: 12.14.5 negative: SyntaxError ---*/ -var x; - -[...x,] = []; +//- elems +[...x,] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-before-rest.js b/src/dstr-assignment/array-rest-before-rest.case similarity index 83% rename from test/language/expressions/assignment/destructuring/array-rest-before-rest.js rename to src/dstr-assignment/array-rest-before-rest.case index 207cb39ba81009272199505334cabad2e469031b..a86de5f458c6d1b8a97c41a887272712b78989c0 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-before-rest.js +++ b/src/dstr-assignment/array-rest-before-rest.case @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > An AssignmentRestElement may not follow another AssignmentRestElement in an AssignmentElementList. +template: syntax es6id: 12.14.5 negative: SyntaxError ---*/ -var x, y; - -[...x, ...y] = []; +//- elems +[...x, ...y] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-elision-invalid.js b/src/dstr-assignment/array-rest-elision-invalid.case similarity index 84% rename from test/language/expressions/assignment/destructuring/array-rest-elision-invalid.js rename to src/dstr-assignment/array-rest-elision-invalid.case index e26ebff5995203b41c2a0fe5c08d9fa30e8ee46e..f002f7169a3bd7af6eac0d52106f7ff865b1503d 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-elision-invalid.js +++ b/src/dstr-assignment/array-rest-elision-invalid.case @@ -2,11 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > ArrayAssignmentPattern may not include elisions following an AssignmentRestElement in a AssignmentElementList. +template: syntax es6id: 12.14.5 negative: SyntaxError ---*/ -[...x,] = []; +//- elems +[...x,] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-elision-iter-abpt.js b/src/dstr-assignment/array-rest-elision-iter-abpt.case similarity index 91% rename from test/language/expressions/assignment/destructuring/array-rest-elision-iter-abpt.js rename to src/dstr-assignment/array-rest-elision-iter-abpt.case index 367cc892fe7d16eb757d0f0cfac3f306d672d449..a84bab56fd4e6ad2f6c300e829a39d7e22ba658e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-elision-iter-abpt.js +++ b/src/dstr-assignment/array-rest-elision-iter-abpt.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when assignment evaluation produces an abrupt completion info: | @@ -17,10 +17,12 @@ info: | IteratorClose(iterator, status). ii. Return Completion(status). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -37,10 +39,12 @@ iterable[Symbol.iterator] = function() { return iterator; }; var x; - -assert.throws(Test262Error, function() { - [ , ...x] = iterable; -}); - +//- error +Test262Error +//- elems +[ , ...x] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-elision.js b/src/dstr-assignment/array-rest-elision.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-elision.js rename to src/dstr-assignment/array-rest-elision.case index 4a0bc1cc61ec575d70c550c3ccabf0a21666a9ec..09a814007ea95cf2b9d14b02847e0fc7a8be89e8 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-elision.js +++ b/src/dstr-assignment/array-rest-elision.case @@ -2,19 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > ArrayAssignmentPattern may include elisions at any position preceeding a AssignmentRestElement in a AssignmentElementList. +template: default es6id: 12.14.5 ---*/ -var value = [1, 2, 3, 4, 5, 6]; +//- setup var x, y; -var result; - -result = [, , x, , ...y] = value; - -assert.sameValue(result, value); +//- elems +[, , x, , ...y] +//- vals +[1, 2, 3, 4, 5, 6] +//- body assert.sameValue(x, 3); assert.sameValue(y.length, 2); assert.sameValue(y[0], 5); diff --git a/test/language/expressions/assignment/destructuring/array-rest-init.js b/src/dstr-assignment/array-rest-init.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-init.js rename to src/dstr-assignment/array-rest-init.case index 2fbe698d94d13b9f102f5e60f4ceca66d93814ce..02c329e2099d0166be285ebe7c87acff2a5ecaa4 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-init.js +++ b/src/dstr-assignment/array-rest-init.case @@ -2,12 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The AssignmentRestElement does not support an initializer. +template: syntax es6id: 12.14.5 negative: SyntaxError ---*/ +//- setup var x; - -[...x = 1] = []; +//- elems +[...x = 1] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-get-err.js b/src/dstr-assignment/array-rest-iter-get-err.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-iter-get-err.js rename to src/dstr-assignment/array-rest-iter-get-err.case index 6cf2f2d45ec5f2d939ec4643403ad0c9ce6e1b1b..7693c779db139b1297f03f69030d1839555dc67f 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-get-err.js +++ b/src/dstr-assignment/array-rest-iter-get-err.case @@ -1,23 +1,27 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Abrupt completion returned from GetIterator +desc: Abrupt completion returned from GetIterator info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] 1. Let iterator be GetIterator(value). 2. ReturnIfAbrupt(iterator). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var x; iterable[Symbol.iterator] = function() { throw new Test262Error(); }; - -assert.throws(Test262Error, function() { - [...x] = iterable; -}); +//- error +Test262Error +//- elems +[...x] +//- vals +iterable diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-nrml-close-skip.js b/src/dstr-assignment/array-rest-iter-nrml-close-skip.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-rest-iter-nrml-close-skip.js rename to src/dstr-assignment/array-rest-iter-nrml-close-skip.case index 5bb22af60b9a42e57fbd74a6e4d15f9cf23a0fe7..627731aa60de21b90bc1c162b62fe7f35659a845 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-nrml-close-skip.js +++ b/src/dstr-assignment/array-rest-iter-nrml-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when assignment evaluation has exhausted the iterator info: | @@ -15,10 +15,12 @@ info: | result). 7. Return result. features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var x; @@ -35,8 +37,10 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -[ ...x ] = iterable; - +//- elems +[ ...x ] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-err.js b/src/dstr-assignment/array-rest-iter-rtrn-close-err.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-err.js rename to src/dstr-assignment/array-rest-iter-rtrn-close-err.case index b86607956f56e2a72e6e29eb03b5211cddad5452..aaeb47a8ddce0f37783d8f2792f4d3bcc6a29581 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-err.js +++ b/src/dstr-assignment/array-rest-iter-rtrn-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "return" completion info: | @@ -28,10 +28,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; function ReturnError() {} @@ -49,8 +51,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [...{}[yield]] = iterable; - unreachable += 1; +//- elems +[...{}[yield]] +//- vals +iterable +//- body +unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-null.js b/src/dstr-assignment/array-rest-iter-rtrn-close-null.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-null.js rename to src/dstr-assignment/array-rest-iter-rtrn-close-null.case index 4b37e9f599eecf207f923981bfab3b1b925b8760..f911aea3f80a45bef7131e0fe6af367a79fcdc5e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close-null.js +++ b/src/dstr-assignment/array-rest-iter-rtrn-close-null.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose throws a TypeError when `return` returns a non-Object value info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] @@ -33,10 +33,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var iterable = {}; var iterator = { return: function() { @@ -49,7 +51,11 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [...{}[yield]] = iterable; +//- elems +[...{}[yield]] +//- vals +iterable +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close.js b/src/dstr-assignment/array-rest-iter-rtrn-close.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close.js rename to src/dstr-assignment/array-rest-iter-rtrn-close.case index da30120406d87c28c68692239fb483e311429e8b..35366c2aa24a86ab2e5d3392bbb4e9b6451f10d6 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-rtrn-close.js +++ b/src/dstr-assignment/array-rest-iter-rtrn-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "return" completion info: | @@ -34,10 +34,12 @@ info: | 7. If completion.[[type]] is throw, return Completion(completion). 8. If innerResult.[[type]] is throw, return Completion(innerResult). features: [Symbol.iterator, generators] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var returnCount = 0; var unreachable = 0; var thisValue = null; @@ -57,8 +59,13 @@ iterable[Symbol.iterator] = function() { }; function* g() { - [...{}[yield]] = iterable; - unreachable += 1; +//- elems +[...{}[yield]] +//- vals +iterable +//- body +unreachable += 1; +//- teardown } iter = g(); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-err.js b/src/dstr-assignment/array-rest-iter-thrw-close-err.case similarity index 93% rename from test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-err.js rename to src/dstr-assignment/array-rest-iter-thrw-close-err.case index f39a1465234a86cdfabab4a19fd37451198dbb73..4c98fb20f5ae9bb41f402d1d920969d11368e22e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-err.js +++ b/src/dstr-assignment/array-rest-iter-thrw-close-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "throw" completion info: | @@ -21,10 +21,12 @@ info: | a. Let lref be the result of evaluating DestructuringAssignmentTarget. b. ReturnIfAbrupt(lref). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var x; @@ -51,9 +53,12 @@ iterable[Symbol.iterator] = function() { return iterator; }; -assert.throws(Test262Error, function() { - [...{}[thrower()]] = iterable; -}); - +//- error +Test262Error +//- elems +[...{}[thrower()]] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-skip.js b/src/dstr-assignment/array-rest-iter-thrw-close-skip.case similarity index 90% rename from test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-skip.js rename to src/dstr-assignment/array-rest-iter-thrw-close-skip.case index 84a4cac82012793f63013b4cb642527b2184eced..d95493775c3ae60e8ed2a4e3cd3d6ccf50d6a1f2 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close-skip.js +++ b/src/dstr-assignment/array-rest-iter-thrw-close-skip.case @@ -1,6 +1,6 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when iteration produces an abrupt completion info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] @@ -12,10 +12,12 @@ info: | 6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var x; @@ -32,10 +34,12 @@ var iterator = { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [...x] = iterable; -}); - +//- error +Test262Error +//- elems +[...x] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close.js b/src/dstr-assignment/array-rest-iter-thrw-close.case similarity index 94% rename from test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close.js rename to src/dstr-assignment/array-rest-iter-thrw-close.case index 8e5b4e634c32a233e62e437c69d31bbbfd3e090f..3028c1afe09fba05dbef0fba726df3e8608943eb 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iter-thrw-close.js +++ b/src/dstr-assignment/array-rest-iter-thrw-close.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces a "throw" completion info: | @@ -27,10 +27,12 @@ info: | 6. Let innerResult be Call(return, iterator, « »). [...] features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var thisValue = null; @@ -56,11 +58,13 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [...{}[thrower()]] = iterable; -}); - +//- error +Test262Error +//- elems +[...{}[thrower()]] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); assert.sameValue(thisValue, iterator, 'correct `this` value'); diff --git a/test/language/expressions/assignment/destructuring/array-rest-iteration.js b/src/dstr-assignment/array-rest-iteration.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-iteration.js rename to src/dstr-assignment/array-rest-iteration.case index 735ee9914ec29690647a4e39a81d992682598969..8f1a8d2d30e95e2a59082279fb6f43b931226827 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-iteration.js +++ b/src/dstr-assignment/array-rest-iteration.case @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > In the presense of an AssignmentRestElement, value iteration exhausts the iterable value; +template: default es6id: 12.14.5.3 features: [generators] ---*/ +//- setup var count = 0; var g = function*() { count += 1; @@ -17,10 +19,10 @@ var g = function*() { yield; count += 1; } -var iter, result, x; - -iter = g(); -result = [...x] = iter; - -assert.sameValue(result, iter); +var x; +//- elems +[...x] +//- vals +g() +//- body assert.sameValue(count, 3); diff --git a/test/language/expressions/assignment/destructuring/array-rest-lref-err.js b/src/dstr-assignment/array-rest-lref-err.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-rest-lref-err.js rename to src/dstr-assignment/array-rest-lref-err.case index 2a083bdceeb112a7dc2f50ef03e18900a7e2ee53..56f4712052949104aa882cdbce6000cf58c105f7 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-lref-err.js +++ b/src/dstr-assignment/array-rest-lref-err.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is called when reference evaluation produces an abrupt completion info: | @@ -21,10 +21,12 @@ info: | a. Let lref be the result of evaluating DestructuringAssignmentTarget. b. ReturnIfAbrupt(lref). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -43,10 +45,12 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [...{}[thrower()]] = iterable; -}); - +//- error +Test262Error +//- elems +[...{}[thrower()]] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 0); assert.sameValue(returnCount, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-lref.js b/src/dstr-assignment/array-rest-lref.case similarity index 90% rename from test/language/expressions/assignment/destructuring/array-rest-lref.js rename to src/dstr-assignment/array-rest-lref.case index 68161c48e8546b2a2963632b8650664089cf3ef5..b16315041c1802fe94e20f28e6af55eb327c7dd2 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-lref.js +++ b/src/dstr-assignment/array-rest-lref.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Reference is evaluated during assignment +desc: Reference is evaluated during assignment info: | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] @@ -20,10 +20,12 @@ info: | b. ReturnIfAbrupt(lref). [...] features: [Symbol.iterator] +template: default es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -40,9 +42,11 @@ var obj = {}; iterable[Symbol.iterator] = function() { return iterator; }; - -[...obj['a' + 'b']] = iterable; - +//- elems +[...obj['a' + 'b']] +//- vals +iterable +//- body assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); assert(!!obj.ab); diff --git a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-invalid.js b/src/dstr-assignment/array-rest-nested-array-invalid.case similarity index 87% rename from test/language/expressions/assignment/destructuring/array-elem-nested-obj-invalid.js rename to src/dstr-assignment/array-rest-nested-array-invalid.case index 1f771e07ad806351d36ed6c74d52a9190d90080a..08eff54e22ecc2c23b5ac48c0c2ee07ff2b9f7f8 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-nested-obj-invalid.js +++ b/src/dstr-assignment/array-rest-nested-array-invalid.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.1 negative: SyntaxError ---*/ -[{ get x() {} }] = [{}]; +//- elems +[...[(x, y)]] +//- vals +[[]] diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-iter-thrw-close-skip.js b/src/dstr-assignment/array-rest-nested-array-iter-thrw-close-skip.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-iter-thrw-close-skip.js rename to src/dstr-assignment/array-rest-nested-array-iter-thrw-close-skip.case index 8d5749624b18b41bfc8a923b30969ceaea0ecf79..c569539803b4c5bf107d71621351ea87c8e668ab 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-iter-thrw-close-skip.js +++ b/src/dstr-assignment/array-rest-nested-array-iter-thrw-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when nested array pattern evaluation produces an abrupt completion info: | @@ -24,10 +24,12 @@ info: | 7. Return the result of performing DestructuringAssignmentEvaluation of nestedAssignmentPattern with A as the argument. features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -46,10 +48,12 @@ var thrower = function() { iterable[Symbol.iterator] = function() { return iterator; }; - -assert.throws(Test262Error, function() { - [...[...{}[thrower()]]] = iterable; -}); - +//- error +Test262Error +//- elems +[...[...{}[thrower()]]] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-null.js b/src/dstr-assignment/array-rest-nested-array-null.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-null.js rename to src/dstr-assignment/array-rest-nested-array-null.case index 73e2a81420564b149d4bf12448ac911a1b01230b..9b68c38f652d0e961c3649aa07440b1cb1463299 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-null.js +++ b/src/dstr-assignment/array-rest-nested-array-null.case @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [null]; -var result, x, y; - -result = [...[x, y]] = value; - -assert.sameValue(result, value); +//- setup +var x, y; +//- elems +[...[x, y]] +//- vals +[null] +//- body assert.sameValue(x, null); assert.sameValue(y, undefined); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-hole.js b/src/dstr-assignment/array-rest-nested-array-undefined-hole.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-hole.js rename to src/dstr-assignment/array-rest-nested-array-undefined-hole.case index a01b0b84eb7c3afe3885b24fb39c7c0b83c0fc65..0b4566e8b45c602dabd3c3f37e7877c74874023a 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-hole.js +++ b/src/dstr-assignment/array-rest-nested-array-undefined-hole.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [ , ]; -var result, x; - -result = [...[x]] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +//- elems +[...[x]] +//- vals +[ , ] +//- body assert.sameValue(x, undefined); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-own.js b/src/dstr-assignment/array-rest-nested-array-undefined-own.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-own.js rename to src/dstr-assignment/array-rest-nested-array-undefined-own.case index 1ba0a502fb7ac368d4c8b49f7c4c57ff9889a315..5da0f9982f4834f4be7f8c1e80f562ac169ec425 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined-own.js +++ b/src/dstr-assignment/array-rest-nested-array-undefined-own.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [undefined]; -var result, x; - -result = [...[x]] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +//- elems +[...[x]] +//- vals +[undefined] +//- body assert.sameValue(x, undefined); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined.js b/src/dstr-assignment/array-rest-nested-array-undefined.case similarity index 78% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined.js rename to src/dstr-assignment/array-rest-nested-array-undefined.case index d8c743a03b1ab3813a5517f1c55a9f64aad662ce..b4662b2b43e9ea3c1f3d435bbd846feb1fc5b269 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-undefined.js +++ b/src/dstr-assignment/array-rest-nested-array-undefined.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = []; -var result, x; - -result = [...[x]] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +//- elems +[...[x]] +//- vals +[] +//- body assert.sameValue(x, undefined); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-expr.js b/src/dstr-assignment/array-rest-nested-array-yield-expr.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-expr.js rename to src/dstr-assignment/array-rest-nested-array-yield-expr.case index 89578a84a5fdfcf025eeab6a72f04a7b78a5dd57..75b97caf06e1da00d67a5a7a0b155ad0b2b015ad 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-expr.js +++ b/src/dstr-assignment/array-rest-nested-array-yield-expr.case @@ -2,32 +2,36 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment and within a generator function body, it should behave as a YieldExpression. +template: default es6id: 12.14.5.3 features: [generators] ---*/ +//- setup var value = [86]; var x = {}; -var assignmentResult, iterationResult, iter; +var iterationResult, iter; iter = (function*() { - assignmentResult = [...[x[yield]]] = value; +//- elems +[...[x[yield]]] +//- vals +[86] +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); iterationResult = iter.next('prop'); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop, 86); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-invalid.js b/src/dstr-assignment/array-rest-nested-array-yield-ident-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-invalid.js rename to src/dstr-assignment/array-rest-nested-array-yield-ident-invalid.case index dc34b696e8bbfe3b29541b9735501eddb82c6e95..995a7f9ff3b8c0ceb6ca359d3ce67cbd911afefb 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-invalid.js +++ b/src/dstr-assignment/array-rest-nested-array-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.3 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -[...[x[yield]]] = []; +//- elems +[...[x[yield]]] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-valid.js b/src/dstr-assignment/array-rest-nested-array-yield-ident-valid.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-valid.js rename to src/dstr-assignment/array-rest-nested-array-yield-ident-valid.case index d60b4ccd110452a3f4725dc73fc164043937c13a..fd5eff61d854ad0fccba2a825b997bccf87cec18 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array-yield-ident-valid.js +++ b/src/dstr-assignment/array-rest-nested-array-yield-ident-valid.case @@ -2,20 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = [86]; +//- setup var yield = 'prop'; var x = {}; -var result; - -result = [...[x[yield]]] = value; - -assert.sameValue(result, value); +//- elems +[...[x[yield]]] +//- vals +[86] +//- body assert.sameValue(x.prop, 86); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-array.js b/src/dstr-assignment/array-rest-nested-array.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-nested-array.js rename to src/dstr-assignment/array-rest-nested-array.case index fd77214f426512e426f1614eb8fa3d93919ad3c1..7f6f6562ac0aa4c23d6246088f79fda0050420eb 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-array.js +++ b/src/dstr-assignment/array-rest-nested-array.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [1, 2, 3]; -var x, result; - -result = [...[x]] = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +[...[x]] +//- vals +[1, 2, 3] +//- body assert.sameValue(x, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-invalid.js b/src/dstr-assignment/array-rest-nested-obj-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-invalid.js rename to src/dstr-assignment/array-rest-nested-obj-invalid.case index 35d467839d923e9d32f9a8033d8b02847447d817..ee38be20ea34f8735ce45c94ae7a97cc7a897a95 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-invalid.js +++ b/src/dstr-assignment/array-rest-nested-obj-invalid.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.1 negative: SyntaxError ---*/ -[...{ get x() {} }] = [[]]; +//- elems +[...{ get x() {} }] +//- vals +[[]] diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-null.js b/src/dstr-assignment/array-rest-nested-obj-null.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-null.js rename to src/dstr-assignment/array-rest-nested-obj-null.case index b5efac41cad1f1231e661cedb7b6f18c64e717bf..4c4eb45c202d55ef3fd770c0b589204b261d3898 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-null.js +++ b/src/dstr-assignment/array-rest-nested-obj-null.case @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [null]; -var result, x, length; - -result = [...{ 0: x, length }] = value; - -assert.sameValue(result, value); +//- setup +var x, length; +//- elems +[...{ 0: x, length }] +//- vals +[null] +//- body assert.sameValue(x, null); assert.sameValue(length, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-hole.js b/src/dstr-assignment/array-rest-nested-obj-undefined-hole.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-hole.js rename to src/dstr-assignment/array-rest-nested-obj-undefined-hole.case index e01715a39eb4b9cb767f3c0f499edecb085be224..54b078e8cadd5604b78dec349f19e1c6ff59dcb9 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-hole.js +++ b/src/dstr-assignment/array-rest-nested-obj-undefined-hole.case @@ -2,18 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [ , ]; -var result, x, length; - -result = [...{ 0: x, length }] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +var length; +//- elems +[...{ 0: x, length }] +//- vals +[ , ] +//- body assert.sameValue(x, undefined); assert.sameValue(length, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-own.js b/src/dstr-assignment/array-rest-nested-obj-undefined-own.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-own.js rename to src/dstr-assignment/array-rest-nested-obj-undefined-own.case index 70735f34ff1e0839f920a99670735f3c3821d5d4..2a6aa15f009204efb65453c3ca50fe9785b3563e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined-own.js +++ b/src/dstr-assignment/array-rest-nested-obj-undefined-own.case @@ -2,18 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = [undefined]; -var result, x, length; - -result = [...{ 0: x, length }] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +var length; +//- elems +[...{ 0: x, length }] +//- vals +[undefined] +//- body assert.sameValue(x, undefined); assert.sameValue(length, 1); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined.js b/src/dstr-assignment/array-rest-nested-obj-undefined.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined.js rename to src/dstr-assignment/array-rest-nested-obj-undefined.case index 53425d44f8616c97563275478212002a5aa241a3..200ab543d6f004afaaf47cf596e78f5e96182899 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-undefined.js +++ b/src/dstr-assignment/array-rest-nested-obj-undefined.case @@ -2,18 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an obect literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. +template: default es6id: 12.14.5.3 ---*/ -var value = []; -var result, x, length; - -result = [...{ 0: x, length }] = value; - -assert.sameValue(result, value); +//- setup +var x = null; +var length; +//- elems +[...{ 0: x, length }] +//- vals +[] +//- body assert.sameValue(x, undefined); assert.sameValue(length, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-expr.js b/src/dstr-assignment/array-rest-nested-obj-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-expr.js rename to src/dstr-assignment/array-rest-nested-obj-yield-expr.case index 0daf86e0c2c24bcc67543a9a9a8fba52207bff1a..c867b58cc341ed90c1dea6b55ac15632b22ce433 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-expr.js +++ b/src/dstr-assignment/array-rest-nested-obj-yield-expr.case @@ -2,31 +2,34 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.3 features: [generators] ---*/ -var value = [{}]; -var assignmentResult, iterationResult, iter, x; +//- setup +var iterationResult, iter, x; iter = (function*() { - assignmentResult = [...{ x = yield }] = value; +//- elems +[...{ x = yield }] +//- vals +[{}] +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(4); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 4); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-invalid.js b/src/dstr-assignment/array-rest-nested-obj-yield-ident-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-invalid.js rename to src/dstr-assignment/array-rest-nested-obj-yield-ident-invalid.case index ebb79b43145e2936bcb838ff5364e4a3096fb134..9759c626ca410e290960103ee020cc1d3e6c6f77 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-invalid.js +++ b/src/dstr-assignment/array-rest-nested-obj-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.3 flags: [onlyStrict] negative: SyntaxError ---*/ -var value = [{}]; -[...{ x = yield }] = value; +//- elems +[...{ x = yield }] +//- vals +[{}] diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-valid.js b/src/dstr-assignment/array-rest-nested-obj-yield-ident-valid.case similarity index 74% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-valid.js rename to src/dstr-assignment/array-rest-nested-obj-yield-ident-valid.case index b220b0dd54fe76401c7b87f5907bb3e56b3b0d9a..2d67dd4514896a656fa3d7fbd9905bb65588373f 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj-yield-ident-valid.js +++ b/src/dstr-assignment/array-rest-nested-obj-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 es6id: 12.14.5.3 flags: [noStrict] ---*/ -var value = [{}]; +//- setup var yield = 2; -var result, iterationResult, iter, x; - -result = [...{ x = yield }] = value; - -assert.sameValue(result, value); +var x; +//- elems +[...{ x = yield }] +//- vals +[{}] +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/array-rest-nested-obj.js b/src/dstr-assignment/array-rest-nested-obj.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-rest-nested-obj.js rename to src/dstr-assignment/array-rest-nested-obj.case index f5812ba5f013ae3f415377afda8ec6efd51ee5a1..f3ac3e7ab9c0a992e2f2dc2fa4501a055ff7abae 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-nested-obj.js +++ b/src/dstr-assignment/array-rest-nested-obj.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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.3 ---*/ -var value = [1, 2, 3]; -var result, x; - -result = [...{ 1: x }] = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +[...{ 1: x }] +//- vals +[1, 2, 3] +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-const.js b/src/dstr-assignment/array-rest-put-const.case similarity index 75% rename from test/language/expressions/assignment/destructuring/array-rest-put-const.js rename to src/dstr-assignment/array-rest-put-const.case index 96bf0d9e8a07b19a034f1762005f052f4f522a2a..67eb6eda54ec327b588be0695d99abf12012a7aa 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-const.js +++ b/src/dstr-assignment/array-rest-put-const.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `const` semantics. +template: error es6id: 12.14.5.3 features: [const] ---*/ +//- setup const c = null; - -assert.throws(TypeError, function() { - [ ...c ] = [1]; -}); +//- error +TypeError +//- elems +[ ...c ] +//- vals +[1] diff --git a/test/language/expressions/assignment/destructuring/array-elem-put-let.js b/src/dstr-assignment/array-rest-put-let.case similarity index 70% rename from test/language/expressions/assignment/destructuring/array-elem-put-let.js rename to src/dstr-assignment/array-rest-put-let.case index 018d8b1a6e36478f2b4690656f100b75a54df47e..9cc0cff482fcb99aa8af0ddc71376ebf5ea445f6 100644 --- a/test/language/expressions/assignment/destructuring/array-elem-put-let.js +++ b/src/dstr-assignment/array-rest-put-let.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `let` semantics. +template: error es6id: 12.14.5.3 features: [let] ---*/ -assert.throws(ReferenceError, function() { - 'use strict'; - [ x ] = []; - let x; -}); +//- error +ReferenceError +//- elems +[ ...x ] +//- vals +[] +//- teardown +let x; diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-no-get.js b/src/dstr-assignment/array-rest-put-prop-ref-no-get.case similarity index 80% rename from test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-no-get.js rename to src/dstr-assignment/array-rest-put-prop-ref-no-get.case index d57bf425f3f303e5bb8db1f34faa86d5feab9a4a..1adb2c2e07d0f7fb7435ed9de27050395588a38b 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-no-get.js +++ b/src/dstr-assignment/array-rest-put-prop-ref-no-get.case @@ -2,15 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. +template: default es6id: 12.14.5.3 ---*/ -var value = [23, 45, 99]; -var x, setValue, result; -x = { +//- setup +var setValue; +var x = { get y() { $ERROR('The property should not be accessed.'); }, @@ -18,10 +19,11 @@ x = { setValue = val; } }; - -result = [...x.y] = value; - -assert.sameValue(result, value); +//- elems +[...x.y] +//- vals +[23, 45, 99] +//- body assert.sameValue(setValue.length, 3); assert.sameValue(setValue[0], 23); assert.sameValue(setValue[1], 45); diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err-iter-close-skip.js b/src/dstr-assignment/array-rest-put-prop-ref-user-err-iter-close-skip.case similarity index 92% rename from test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err-iter-close-skip.js rename to src/dstr-assignment/array-rest-put-prop-ref-user-err-iter-close-skip.case index 513f433032c23b54ffabe74be13a633e3944eec3..b82be99fe1befe2b28f2e4ac1f0856491a852356 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err-iter-close-skip.js +++ b/src/dstr-assignment/array-rest-put-prop-ref-user-err-iter-close-skip.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > IteratorClose is not called when value assignment produces an abrupt completion. info: | @@ -25,10 +25,12 @@ info: | ArrayLiteral, then a. Return PutValue(lref, A). features: [Symbol.iterator] +template: error es6id: 12.14.5.2 esid: sec-runtime-semantics-destructuringassignmentevaluation ---*/ +//- setup var nextCount = 0; var returnCount = 0; var iterable = {}; @@ -49,9 +51,12 @@ var obj = Object.defineProperty({}, 'poisoned', { iterable[Symbol.iterator] = function() { return iterator; }; -assert.throws(Test262Error, function() { - [...obj.poisoned] = iterable; -}); - +//- error +Test262Error +//- elems +[...obj.poisoned] +//- vals +iterable +//- teardown assert.sameValue(nextCount, 1); assert.sameValue(returnCount, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err.js b/src/dstr-assignment/array-rest-put-prop-ref-user-err.case similarity index 76% rename from test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err.js rename to src/dstr-assignment/array-rest-put-prop-ref-user-err.case index 1b03ef780e1644a70e6317315c4e2ee4a00e2717..0f4cc41d6cb9d9df651f3e77609426266254e0fb 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref-user-err.js +++ b/src/dstr-assignment/array-rest-put-prop-ref-user-err.case @@ -2,19 +2,22 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Any error raised as a result of setting the value should be forwarded to the runtime. +template: error es6id: 12.14.5.3 ---*/ -var value = [23]; +//- setup var x = { set y(val) { throw new Test262Error(); } }; - -assert.throws(Test262Error, function() { - [...x.y] = value; -}); +//- error +Test262Error +//- elems +[...x.y] +//- vals +[23] diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref.js b/src/dstr-assignment/array-rest-put-prop-ref.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-rest-put-prop-ref.js rename to src/dstr-assignment/array-rest-put-prop-ref.case index bdc04a820024f4e27f95a6694aafa625389dc985..fda1af6dc0065c6333a52af541f082e861e2ffe3 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-prop-ref.js +++ b/src/dstr-assignment/array-rest-put-prop-ref.case @@ -2,19 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. +template: default es6id: 12.14.5.3 ---*/ -var value = [4, 3, 2]; +//- setup var x = {}; -var result; - -result = [...x.y] = value; - -assert.sameValue(result, value); +//- elems +[...x.y] +//- vals +[4, 3, 2] +//- body assert.sameValue(x.y.length, 3); assert.sameValue(x.y[0], 4); assert.sameValue(x.y[1], 3); diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-no-strict.js b/src/dstr-assignment/array-rest-put-unresolvable-no-strict.case similarity index 81% rename from test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-no-strict.js rename to src/dstr-assignment/array-rest-put-unresolvable-no-strict.case index d904f55f2a74a43a592e14f36649abee954facad..9c95a9b9d17b3ec518bc1078ba5b7c5ac0124f8e 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-no-strict.js +++ b/src/dstr-assignment/array-rest-put-unresolvable-no-strict.case @@ -2,15 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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.3 flags: [noStrict] ---*/ +//- setup { - [ ...unresolvable ] = []; +//- elems +[ ...unresolvable ] +//- vals +[] +//- teardown } assert.sameValue(unresolvable.length, 0); diff --git a/test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-strict.js b/src/dstr-assignment/array-rest-put-unresolvable-strict.case similarity index 77% rename from test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-strict.js rename to src/dstr-assignment/array-rest-put-unresolvable-strict.case index 43bad4b253bfc8909ab592aa0d9ce4778855cd3e..52cc2305a449a0bddea4879a2b557566c8f9e282 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-put-unresolvable-strict.js +++ b/src/dstr-assignment/array-rest-put-unresolvable-strict.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. +template: error es6id: 12.14.5.3 flags: [onlyStrict] ---*/ -assert.throws(ReferenceError, function() { - [ ...unresolvable ] = []; -}); +//- error +ReferenceError +//- elems +[ ...unresolvable ] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-yield-expr.js b/src/dstr-assignment/array-rest-yield-expr.case similarity index 79% rename from test/language/expressions/assignment/destructuring/array-rest-yield-expr.js rename to src/dstr-assignment/array-rest-yield-expr.case index e373478de864e2b07d6883789d22e173b8e7042b..533800254b1073ecaca1d6903a788e590e3c884c 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-yield-expr.js +++ b/src/dstr-assignment/array-rest-yield-expr.case @@ -2,32 +2,35 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and within the body of a generator function, it should behave as a YieldExpression. +template: default es6id: 12.14.5 features: [generators] ---*/ -var value = [33, 44, 55]; +//- setup var x = {}; -var assignmentResult, iterationResult, iter; +var iterationResult, iter; iter = (function*() { - assignmentResult = [...x[yield]] = value; +//- elems +[...x[yield]] +//- vals +[33, 44, 55] +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); iterationResult = iter.next('prop'); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop.length, 3); diff --git a/test/language/expressions/assignment/destructuring/array-rest-yield-ident-invalid.js b/src/dstr-assignment/array-rest-yield-ident-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/array-rest-yield-ident-invalid.js rename to src/dstr-assignment/array-rest-yield-ident-invalid.case index 427fe68038fdc5ab1c089c3c4050eaf1abd99c00..d635a7c5a6635c917237603928a1ab303a634666 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-yield-ident-invalid.js +++ b/src/dstr-assignment/array-rest-yield-ident-invalid.case @@ -2,14 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and outside of a generator function body, it should behave as an IdentifierReference. +template: syntax es6id: 12.14.5 flags: [onlyStrict] negative: SyntaxError ---*/ +//- setup var x = {}; -[...x[yield]] = []; +//- elems +[...x[yield]] +//- vals +[] diff --git a/test/language/expressions/assignment/destructuring/array-rest-yield-ident-valid.js b/src/dstr-assignment/array-rest-yield-ident-valid.case similarity index 82% rename from test/language/expressions/assignment/destructuring/array-rest-yield-ident-valid.js rename to src/dstr-assignment/array-rest-yield-ident-valid.case index 4f56b9abe8768287f6f090c37fa5a182f3f929eb..8168c4e81d99c4fd006e464259f3f1cd32338973 100644 --- a/test/language/expressions/assignment/destructuring/array-rest-yield-ident-valid.js +++ b/src/dstr-assignment/array-rest-yield-ident-valid.case @@ -2,22 +2,23 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and outside of a generator function body, it should behave as an IdentifierReference. +template: default es6id: 12.14.5 flags: [noStrict] ---*/ -var value = [33, 44, 55]; +//- setup var yield = 'prop'; var x = {}; -var result; - -result = [...x[yield]] = value; - -assert.sameValue(result, value); +//- elems +[...x[yield]] +//- vals +[33, 44, 55] +//- body assert.sameValue(x.prop.length, 3); assert.sameValue(x.prop[0], 33); assert.sameValue(x.prop[1], 44); diff --git a/src/dstr-assignment/default/assignment-expr.template b/src/dstr-assignment/default/assignment-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..17c6a038707e2ed32097b8084f68057fb4e8e3c2 --- /dev/null +++ b/src/dstr-assignment/default/assignment-expr.template @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/assignment/dstr- +name: > + AssignmentExpression +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +var result; +var vals = /*{ vals }*/; + +result = /*{ elems }*/ = vals; + +/*{ body }*/ + +assert.sameValue(result, vals); diff --git a/src/dstr-assignment/default/for-of.template b/src/dstr-assignment/default/for-of.template new file mode 100644 index 0000000000000000000000000000000000000000..36446c0af3de4f7c7e7084c708b2d749198bfad2 --- /dev/null +++ b/src/dstr-assignment/default/for-of.template @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-of/dstr- +name: > + For..of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +info: | + IterationStatement : + for ( 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 + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +var counter = 0; + +for (/*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/src/dstr-assignment/error/assignment-expr.template b/src/dstr-assignment/error/assignment-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..4d9ece3757457040696578d10cb5dc7241b272af --- /dev/null +++ b/src/dstr-assignment/error/assignment-expr.template @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/assignment/dstr- +name: > + AssignmentExpression +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +assert.throws(/*{ error }*/, function() { + 0, /*{ elems }*/ = /*{ vals }*/; +}); diff --git a/src/dstr-assignment/error/for-of.template b/src/dstr-assignment/error/for-of.template new file mode 100644 index 0000000000000000000000000000000000000000..8484d8713500fb6b9192ab483bf3a8cac42693b3 --- /dev/null +++ b/src/dstr-assignment/error/for-of.template @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-of/dstr- +name: > + For..of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +info: | + IterationStatement : + for ( 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 + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ + +var counter = 0; + +assert.throws(/*{ error }*/, function() { + for (/*{ elems }*/ of [/*{ vals }*/]) { + counter += 1; + } + counter += 1; +}); + +assert.sameValue(counter, 0); diff --git a/src/dstr-assignment/obj-empty-bool.case b/src/dstr-assignment/obj-empty-bool.case new file mode 100644 index 0000000000000000000000000000000000000000..5e10c238a9b9d3befe15288aa59a7fa7c4099f19 --- /dev/null +++ b/src/dstr-assignment/obj-empty-bool.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 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 +es6id: 12.14.5.2 +---*/ + +//- elems +{} +//- vals +false diff --git a/src/dstr-assignment/obj-empty-null.case b/src/dstr-assignment/obj-empty-null.case new file mode 100644 index 0000000000000000000000000000000000000000..0d0c6dd2e5f51bbe1341472f45cc79df1e49a6df --- /dev/null +++ b/src/dstr-assignment/obj-empty-null.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 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 (null value) +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +{} +//- vals +null diff --git a/src/dstr-assignment/obj-empty-num.case b/src/dstr-assignment/obj-empty-num.case new file mode 100644 index 0000000000000000000000000000000000000000..582044a4a5684086f4e1433be326abe89ee618a7 --- /dev/null +++ b/src/dstr-assignment/obj-empty-num.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 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 +es6id: 12.14.5.2 +---*/ + +//- elems +{} +//- vals +0 diff --git a/src/dstr-assignment/obj-empty-obj.case b/src/dstr-assignment/obj-empty-obj.case new file mode 100644 index 0000000000000000000000000000000000000000..f4fae61480b2f935c1c5a2788b7d6911144b5c14 --- /dev/null +++ b/src/dstr-assignment/obj-empty-obj.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 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 +es6id: 12.14.5.2 +---*/ + +//- elems +{} +//- vals +{} diff --git a/src/dstr-assignment/obj-empty-string.case b/src/dstr-assignment/obj-empty-string.case new file mode 100644 index 0000000000000000000000000000000000000000..97542fe7eef9d8240e7135bcde5dcaf871e109a1 --- /dev/null +++ b/src/dstr-assignment/obj-empty-string.case @@ -0,0 +1,15 @@ +// Copyright (C) 2015 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 +es6id: 12.14.5.2 +---*/ + +//- elems +{} +//- vals +'' diff --git a/src/dstr-assignment/obj-empty-symbol.case b/src/dstr-assignment/obj-empty-symbol.case new file mode 100644 index 0000000000000000000000000000000000000000..429758940784a68bde81b740a9082c16c89ef258 --- /dev/null +++ b/src/dstr-assignment/obj-empty-symbol.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +es6id: 12.14.5.2 +features: [Symbol] +---*/ + +//- setup +var s = Symbol(); +//- elems +{} +//- vals +s diff --git a/src/dstr-assignment/obj-empty-undef.case b/src/dstr-assignment/obj-empty-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..7c35e66be709da23c5524efea467ae7bf1ca63e0 --- /dev/null +++ b/src/dstr-assignment/obj-empty-undef.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 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 (undefined value) +template: error +es6id: 12.14.5.2 +---*/ + +//- error +TypeError +//- elems +{} +//- vals +undefined diff --git a/src/dstr-assignment/obj-id-identifier-resolution-first.case b/src/dstr-assignment/obj-id-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..c4398ae47caee0ff4cdbd98689e466824922e0bf --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-resolution-first.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +var x = null; +var y; +//- elems +{ x, y } +//- vals +{ x: 3 } +//- body +assert.sameValue(x, 3); diff --git a/src/dstr-assignment/obj-id-identifier-resolution-last.case b/src/dstr-assignment/obj-id-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..0997e5411fb978a6f6d518a09d609c407e9d7146 --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-resolution-last.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +var x = null; +var w; +//- elems +{ w, x } +//- vals +{ x: 4 } +//- body +assert.sameValue(x, 4); diff --git a/src/dstr-assignment/obj-id-identifier-resolution-lone.case b/src/dstr-assignment/obj-id-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..80e684f057716b054b06afffc3bee78e3444fcf9 --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-resolution-lone.case @@ -0,0 +1,17 @@ +// Copyright (C) 2015 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 +var x = null; +//- elems +{ x, } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); diff --git a/src/dstr-assignment/obj-id-identifier-resolution-middle.case b/src/dstr-assignment/obj-id-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..8dece135d6f61d888d40475b2fa54dd973367fa8 --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-resolution-middle.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +var x = null; +var w, y; +//- elems +{ w, x, y } +//- vals +{ x: 5 } +//- body +assert.sameValue(x, 5); diff --git a/src/dstr-assignment/obj-id-identifier-resolution-trlng.case b/src/dstr-assignment/obj-id-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..ed959bbd9c8bd060074a6bc30abf48ca08cb779f --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-resolution-trlng.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +var x = null; +//- elems +{ x } +//- vals +{ x: 1 } +//- body +assert.sameValue(x, 1); diff --git a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-expr.js b/src/dstr-assignment/obj-id-identifier-yield-expr.case similarity index 57% rename from test/language/expressions/assignment/destructuring/obj-id-identifier-yield-expr.js rename to src/dstr-assignment/obj-id-identifier-yield-expr.case index 3ec7986c31f72fedd6e42161e8ac6954bacff0be..8dc18230f51265a7333d1b6cf21661e276f21e0b 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-expr.js +++ b/src/dstr-assignment/obj-id-identifier-yield-expr.case @@ -2,15 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > - `yield` is not a valid IdentifierReference in an AssignmentProperty within - generator function bodies. +desc: > + yield is not a valid IdentifierReference in an AssignmentProperty within + generator function bodies. +template: syntax es6id: 12.14.5 flags: [noStrict] features: [generators] negative: SyntaxError ---*/ +//- setup (function*() { - { yield } = {}; +//- elems +{ yield } +//- vals +{} +//- teardown }); diff --git a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-invalid.js b/src/dstr-assignment/obj-id-identifier-yield-ident-invalid.case similarity index 57% rename from test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-invalid.js rename to src/dstr-assignment/obj-id-identifier-yield-ident-invalid.case index c5846e5bb3d4bb5e85a8100d352ff6b6694e8186..83c135da48db12bf7910d00f47d14e8c208026a8 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-id-identifier-yield-ident-invalid.case @@ -2,12 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > - `yield` is not a valid IdentifierReference in an AssignmentProperty within - strict mode code. +desc: > + yield is not a valid IdentifierReference in an AssignmentProperty within + strict mode code. +template: syntax es6id: 12.14.5 flags: [onlyStrict] negative: SyntaxError ---*/ -var { yield } = {}; +//- elems +{ yield } +//- vals +{} diff --git a/src/dstr-assignment/obj-id-identifier-yield-ident-valid.case b/src/dstr-assignment/obj-id-identifier-yield-ident-valid.case new file mode 100644 index 0000000000000000000000000000000000000000..fb7ce1808c4b7b3b3f4596a16f1ef56ab7902c09 --- /dev/null +++ b/src/dstr-assignment/obj-id-identifier-yield-ident-valid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + yield is a valid IdentifierReference in an AssignmentProperty outside of + strict mode and generator functions. +template: default +es6id: 12.14.5 +flags: [noStrict] +---*/ + +//- setup +var yield; +//- elems +{ yield } +//- vals +{ yield: 3 } +//- body +assert.sameValue(yield, 3); diff --git a/src/dstr-assignment/obj-id-init-assignment-missing.case b/src/dstr-assignment/obj-id-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..7ef57ff0f62268170b0d11cdc4af7133459bb8aa --- /dev/null +++ b/src/dstr-assignment/obj-id-init-assignment-missing.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); diff --git a/src/dstr-assignment/obj-id-init-assignment-null.case b/src/dstr-assignment/obj-id-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..698a2377fc809655bd2f077366c0a80369237d5e --- /dev/null +++ b/src/dstr-assignment/obj-id-init-assignment-null.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ x = 1 } +//- vals +{ x: null } +//- body +assert.sameValue(x, null); diff --git a/src/dstr-assignment/obj-id-init-assignment-truthy.case b/src/dstr-assignment/obj-id-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..9ee34246c42dfe2cb987fb0efdc764610331a27e --- /dev/null +++ b/src/dstr-assignment/obj-id-init-assignment-truthy.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ x = 1 } +//- vals +{ x: 2 } +//- body +assert.sameValue(x, 2); diff --git a/src/dstr-assignment/obj-id-init-assignment-undef.case b/src/dstr-assignment/obj-id-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..beb088f126bae6fa01d5b620f058b640c529f25a --- /dev/null +++ b/src/dstr-assignment/obj-id-init-assignment-undef.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ x = 1 } +//- vals +{ x: undefined } +//- body +assert.sameValue(x, 1); diff --git a/src/dstr-assignment/obj-id-init-evaluation.case b/src/dstr-assignment/obj-id-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..c5892ff5366461ed928d92d65e9c51be94219254 --- /dev/null +++ b/src/dstr-assignment/obj-id-init-evaluation.case @@ -0,0 +1,21 @@ +// Copyright (C) 2015 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 +var flag1 = false; +var flag2 = false; +var x, y; +//- elems +{ x = flag1 = true, y = flag2 = true } +//- vals +{ y: 1 } +//- body +assert.sameValue(flag1, true); +assert.sameValue(flag2, false); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-arrow.js b/src/dstr-assignment/obj-id-init-fn-name-arrow.case similarity index 84% rename from test/language/expressions/assignment/destructuring/obj-id-init-fn-name-arrow.js rename to src/dstr-assignment/obj-id-init-fn-name-arrow.case index 53075d76e6c9a9246b955dea3e3c8fde8dce94ea..ba923bacb797e98173ca0a944e92068af1651fb2 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-arrow.js +++ b/src/dstr-assignment/obj-id-init-fn-name-arrow.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ArrowFunction) +desc: Assignment of function `name` attribute (ArrowFunction) +template: default es6id: 12.14.5.2 info: > AssignmentProperty : IdentifierReference Initializeropt @@ -17,10 +18,13 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var arrow; - -({ arrow = () => {} } = {}); - +//- elems +{ arrow = () => {} } +//- vals +{} +//- body assert.sameValue(arrow.name, 'arrow'); verifyNotEnumerable(arrow, 'name'); verifyNotWritable(arrow, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-class.js b/src/dstr-assignment/obj-id-init-fn-name-class.case similarity index 79% rename from test/language/expressions/assignment/destructuring/obj-id-init-fn-name-class.js rename to src/dstr-assignment/obj-id-init-fn-name-class.case index 3c20598cb5b6b69430b79c20d8ca3420c5e5354c..69598a67548a97b7e32cc8385684dd0397a76c11 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-class.js +++ b/src/dstr-assignment/obj-id-init-fn-name-class.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ClassExpression) +desc: Assignment of function `name` attribute (ClassExpression) +template: default es6id: 12.14.5.2 info: > AssignmentProperty : IdentifierReference Initializeropt @@ -18,12 +19,14 @@ includes: [propertyHelper.js] features: [class] ---*/ +//- setup var xCls, cls; - -({ xCls = class x {} } = {}); -({ cls = class {} } = {}); - -assert(xCls.name !== 'xCls'); +//- elems +{ xCls = class x {}, cls = class {} } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); assert.sameValue(cls.name, 'cls'); verifyNotEnumerable(cls, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-cover.js b/src/dstr-assignment/obj-id-init-fn-name-cover.case similarity index 83% rename from test/language/expressions/assignment/destructuring/obj-id-init-fn-name-cover.js rename to src/dstr-assignment/obj-id-init-fn-name-cover.case index c220f3740825c98a8ed3d260d98fc0301a599ba1..b0d92b229f6c1a534132db1f760a03abe2c9e5dd 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-cover.js +++ b/src/dstr-assignment/obj-id-init-fn-name-cover.case @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default es6id: 12.14.5.2 info: > AssignmentProperty : IdentifierReference Initializeropt @@ -18,12 +19,14 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var xCover, cover; - -({ xCover = (0, function() {}) } = {}); -({ cover = (function() {}) } = {}); - -assert(xCover.name !== 'xCover'); +//- elems +{ xCover = (0, function() {}), cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); assert.sameValue(cover.name, 'cover'); verifyNotEnumerable(cover, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-fn.js b/src/dstr-assignment/obj-id-init-fn-name-fn.case similarity index 78% rename from test/language/expressions/assignment/destructuring/obj-id-init-fn-name-fn.js rename to src/dstr-assignment/obj-id-init-fn-name-fn.case index 269960e3bbfc200c6b8a93acfc1ccd7650aec1c0..28729746ac29da26249e25e8cb7bfacf2c973436 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-fn.js +++ b/src/dstr-assignment/obj-id-init-fn-name-fn.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (FunctionExpression) +desc: Assignment of function `name` attribute (FunctionExpression) +template: default es6id: 12.14.5.2 info: > AssignmentProperty : IdentifierReference Initializeropt @@ -17,12 +18,14 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var xFn, fn; - -({ xFn = function x() {} } = {}); -({ fn = function() {} } = {}); - -assert(xFn.name !== 'xFn'); +//- elems +{ xFn = function x() {}, fn = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFn.name, 'xFn'); assert.sameValue(fn.name, 'fn'); verifyNotEnumerable(fn, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-gen.js b/src/dstr-assignment/obj-id-init-fn-name-gen.case similarity index 78% rename from test/language/expressions/assignment/destructuring/obj-id-init-fn-name-gen.js rename to src/dstr-assignment/obj-id-init-fn-name-gen.case index 9ae0f31a76467917a4c79b1879618f0976d65f4d..712672024b4581bf82f37b49bc02e2a0b35b2323 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-fn-name-gen.js +++ b/src/dstr-assignment/obj-id-init-fn-name-gen.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (GeneratorExpression) +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default es6id: 12.14.5.2 info: > AssignmentProperty : IdentifierReference Initializeropt @@ -18,12 +19,14 @@ includes: [propertyHelper.js] features: [generators] ---*/ +//- setup var xGen, gen; - -({ xGen = function* x() {} } = {}); -({ gen = function*() {} } = {}); - -assert(xGen.name !== 'xGen'); +//- elems +{ xGen = function* x() {}, gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); assert.sameValue(gen.name, 'gen'); verifyNotEnumerable(gen, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-in.js b/src/dstr-assignment/obj-id-init-in.case similarity index 68% rename from test/language/expressions/assignment/destructuring/obj-id-init-in.js rename to src/dstr-assignment/obj-id-init-in.case index 5626c44b3a466b938312cdeeab4084612f7289ae..fd5f36c78b1db29e27418d15a117aa5994fdf905 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-in.js +++ b/src/dstr-assignment/obj-id-init-in.case @@ -2,15 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The Initializer in an AssignmentProperty may be an `in` expression. +template: default es6id: 12.14.5 ---*/ -var value = {}; -var result, prop; - -result = { prop = 'x' in {} } = value; - -assert.sameValue(result, value); +//- setup +var prop; +//- elems +{ prop = 'x' in {} } +//- vals +{} +//- body assert.sameValue(prop, false); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-let.js b/src/dstr-assignment/obj-id-init-let.case similarity index 69% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-let.js rename to src/dstr-assignment/obj-id-init-let.case index 492454ba1630ea29a61382e85a2886f1901a8573..8581905f16bab2630d155d65c801be7ede3fad33 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-let.js +++ b/src/dstr-assignment/obj-id-init-let.case @@ -2,15 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Value retrieval of Initializer obeys `let` semantics. +template: error es6id: 12.14.5.4 features: [let] ---*/ +//- setup var x; - -assert.throws(ReferenceError, function() { - ({ x: x = y } = {}); - let y; -}); +//- error +ReferenceError +//- elems +{ x = y } +//- vals +{} +//- teardown +let y; diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-order.js b/src/dstr-assignment/obj-id-init-order.case similarity index 71% rename from test/language/expressions/assignment/destructuring/obj-id-init-order.js rename to src/dstr-assignment/obj-id-init-order.case index cdec7decf0e6f1344c75239428446d0f2ced2421..a65a5665129903ba323a6df84fd7b1fb5584b5ff 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-order.js +++ b/src/dstr-assignment/obj-id-init-order.case @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Initializer values should be assigned in left-to-right order. +template: default es6id: 12.14.5.4 ---*/ -var value = {}; +//- setup var x = 0; -var a, b, result; - -result = { a = x += 1, b = x *= 2 } = value; - -assert.sameValue(result, value); +var a, b; +//- elems +{ a = x += 1, b = x *= 2 } +//- vals +{} +//- body assert.sameValue(a, 1); assert.sameValue(b, 2); assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-simple-no-strict.js b/src/dstr-assignment/obj-id-init-simple-no-strict.case similarity index 67% rename from test/language/expressions/assignment/destructuring/obj-id-init-simple-no-strict.js rename to src/dstr-assignment/obj-id-init-simple-no-strict.case index 79b976fad4aff6d79658ed4e84a0d5164f094abe..b44e5bd09452f245c9f4f0e441ea55a532ad86a0 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-simple-no-strict.js +++ b/src/dstr-assignment/obj-id-init-simple-no-strict.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Evaluation of DestructuringAssignmentTarget. +template: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = {}; -var eval, arguments, result; - -result = { eval = 3, arguments = 4 } = value; - -assert.sameValue(result, value); +//- setup +var eval, arguments; +//- elems +{ eval = 3, arguments = 4 } +//- vals +{} +//- body assert.sameValue(eval, 3); assert.sameValue(arguments, 4); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-simple-strict.js b/src/dstr-assignment/obj-id-init-simple-strict.case similarity index 83% rename from test/language/expressions/assignment/destructuring/obj-id-init-simple-strict.js rename to src/dstr-assignment/obj-id-init-simple-strict.case index da9c5f017e569576f5c473564cb585745f9b7406..b2faabe69914ca737d009d0b99dc0c6bcbef2eeb 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-simple-strict.js +++ b/src/dstr-assignment/obj-id-init-simple-strict.case @@ -2,12 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > It is a Syntax Error if IsValidSimpleAssignmentTarget of IdentifierReference is false. +template: syntax es6id: 12.14.5.1 flags: [onlyStrict] negative: SyntaxError ---*/ -({ eval = 0 } = {}); +//- elems +{ eval = 0 } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-yield-expr.js b/src/dstr-assignment/obj-id-init-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-id-init-yield-expr.js rename to src/dstr-assignment/obj-id-init-yield-expr.case index 2991a435e9734157d5a7d22334f892d6e3b706fb..38e44e7e7fe6b7301d35be9c6f3f960757b0ae44 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-yield-expr.js +++ b/src/dstr-assignment/obj-id-init-yield-expr.case @@ -2,19 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5 features: [generators] ---*/ -var value = {}; -var assignmentResult, iterationResult, x, iter; +//- setup +var iterationResult, x, iter; iter = (function*() { - assignmentResult = { x = yield } = value; +//- elems +{ x = yield } +//- vals +{} +//- teardown }()); iterationResult = iter.next(); @@ -22,11 +27,9 @@ iterationResult = iter.next(); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); -assert.sameValue(assignmentResult, undefined); iterationResult = iter.next(3); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 3); -assert.sameValue(assignmentResult, value); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-invalid.js b/src/dstr-assignment/obj-id-init-yield-ident-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-invalid.js rename to src/dstr-assignment/obj-id-init-yield-ident-invalid.case index 3edd831389aa454cbfaecb87b6b6c5eaea830e0b..3d8d12f933bfd6cabd5378cb91e30222fb614519 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-id-init-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -0, { x = yield } = {}; +//- elems +{ x = yield } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-valid.js b/src/dstr-assignment/obj-id-init-yield-ident-valid.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-valid.js rename to src/dstr-assignment/obj-id-init-yield-ident-valid.case index 4759be1e296c02023efb74c3dd142eba4a0095b1..93c9bc6af8013e7564dc7540ca4d24fd4d8ed222 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-yield-ident-valid.js +++ b/src/dstr-assignment/obj-id-init-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5 flags: [noStrict] ---*/ -var value = {}; +//- setup var yield = 3; -var result, x; - -result = { x = yield } = value; - -assert.sameValue(result, value); +var x; +//- elems +{ x = yield } +//- vals +{} +//- body assert.sameValue(x, 3); diff --git a/test/language/expressions/assignment/destructuring/obj-id-put-const.js b/src/dstr-assignment/obj-id-put-const.case similarity index 74% rename from test/language/expressions/assignment/destructuring/obj-id-put-const.js rename to src/dstr-assignment/obj-id-put-const.case index 79c801d261da7233a7f6e62657eb7b85a697a8de..a6905afde8280af73a573434515c29966b1ab3f3 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-put-const.js +++ b/src/dstr-assignment/obj-id-put-const.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `const` semantics. +template: error es6id: 12.14.5.4 features: [const] ---*/ +//- setup const c = null; - -assert.throws(TypeError, function() { - ({ c } = { c: 1 }); -}); +//- error +TypeError +//- elems +{ c } +//- vals +{ c: 1 } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-let.js b/src/dstr-assignment/obj-id-put-let.case similarity index 71% rename from test/language/expressions/assignment/destructuring/obj-prop-put-let.js rename to src/dstr-assignment/obj-id-put-let.case index 98080dced963c2f458b510d78ecd99c89253f4a7..751878afe62bbf1d3a349144628c5f98e889c59d 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-let.js +++ b/src/dstr-assignment/obj-id-put-let.case @@ -2,13 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `let` semantics. +template: error es6id: 12.14.5.4 features: [let] ---*/ -assert.throws(ReferenceError, function() { - ({ a: x } = {}); - let x; -}); +//- error +ReferenceError +//- elems +{ x } +//- vals +{} +//- teardown +let x; diff --git a/test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-no-strict.js b/src/dstr-assignment/obj-id-put-unresolvable-no-strict.case similarity index 81% rename from test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-no-strict.js rename to src/dstr-assignment/obj-id-put-unresolvable-no-strict.case index e98a59f6f233bdd584881232d9331f758527c1e6..250d500a52b54f50fab728af922107158a192269 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-no-strict.js +++ b/src/dstr-assignment/obj-id-put-unresolvable-no-strict.case @@ -2,15 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 { - ({ unresolvable } = {}); +//- elems +{ unresolvable } +//- vals +{} +//- teardown } assert.sameValue(unresolvable, undefined); diff --git a/test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-strict.js b/src/dstr-assignment/obj-id-put-unresolvable-strict.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-strict.js rename to src/dstr-assignment/obj-id-put-unresolvable-strict.case index d205e5f035199915fb0acf7dfd73022621105041..6dd866725c1de780589b506f2bcfefa31da78b98 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-put-unresolvable-strict.js +++ b/src/dstr-assignment/obj-id-put-unresolvable-strict.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. +template: error es6id: 12.14.5.4 flags: [onlyStrict] ---*/ -assert.throws(ReferenceError, function() { - ({ unresolvable } = {}); -}); +//- error +ReferenceError +//- elems +{ unresolvable } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-id-simple-no-strict.js b/src/dstr-assignment/obj-id-simple-no-strict.case similarity index 65% rename from test/language/expressions/assignment/destructuring/obj-id-simple-no-strict.js rename to src/dstr-assignment/obj-id-simple-no-strict.case index f2e924ab47a355af610d6d1db33d057f483d3e72..a191f225332f656fbb08541b78f5dafec3b5dbeb 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-simple-no-strict.js +++ b/src/dstr-assignment/obj-id-simple-no-strict.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Evaluation of DestructuringAssignmentTarget. +template: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = { eval: 1, arguments: 2 }; -var eval, arguments, result; - -result = { eval, arguments } = value; - -assert.sameValue(result, value); +//- setup +var eval, arguments; +//- elems +{ eval, arguments } +//- vals +{ eval: 1, arguments: 2 } +//- teardown assert.sameValue(eval, 1); assert.sameValue(arguments, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-id-simple-strict.js b/src/dstr-assignment/obj-id-simple-strict.case similarity index 84% rename from test/language/expressions/assignment/destructuring/obj-id-simple-strict.js rename to src/dstr-assignment/obj-id-simple-strict.case index af7d5a1eeb1b664096e2f9c12ec93480c1ee0282..19e92bb6219d2447a7983179d22f8291c021bd9e 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-simple-strict.js +++ b/src/dstr-assignment/obj-id-simple-strict.case @@ -2,12 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > It is a Syntax Error if IsValidSimpleAssignmentTarget of IdentifierReference is false. +template: syntax es6id: 12.14.5.1 flags: [onlyStrict] negative: SyntaxError ---*/ -({ eval } = {}); +//- elems +{ eval } +//- vals +{} diff --git a/src/dstr-assignment/obj-prop-elem-init-assignment-missing.case b/src/dstr-assignment/obj-prop-elem-init-assignment-missing.case new file mode 100644 index 0000000000000000000000000000000000000000..36b99b38d978448180018e737e8d114785bb8372 --- /dev/null +++ b/src/dstr-assignment/obj-prop-elem-init-assignment-missing.case @@ -0,0 +1,20 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ y: x = 1 } +//- vals +{} +//- body +assert.sameValue(x, 1); diff --git a/src/dstr-assignment/obj-prop-elem-init-assignment-null.case b/src/dstr-assignment/obj-prop-elem-init-assignment-null.case new file mode 100644 index 0000000000000000000000000000000000000000..aac88b6d002f8fd81310660e9c3ae87c13edc03e --- /dev/null +++ b/src/dstr-assignment/obj-prop-elem-init-assignment-null.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ y: x = 1 } +//- vals +{ y: null } +//- body +assert.sameValue(x, null); diff --git a/src/dstr-assignment/obj-prop-elem-init-assignment-truthy.case b/src/dstr-assignment/obj-prop-elem-init-assignment-truthy.case new file mode 100644 index 0000000000000000000000000000000000000000..668c0a0b6f7831443828cbb42b0334d9583d162e --- /dev/null +++ b/src/dstr-assignment/obj-prop-elem-init-assignment-truthy.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ y: x = 1 } +//- vals +{ y: 2 } +//- body +assert.sameValue(x, 2); diff --git a/src/dstr-assignment/obj-prop-elem-init-assignment-undef.case b/src/dstr-assignment/obj-prop-elem-init-assignment-undef.case new file mode 100644 index 0000000000000000000000000000000000000000..abf1f527bcbd32bda191460be1b26b1d5e690bb5 --- /dev/null +++ b/src/dstr-assignment/obj-prop-elem-init-assignment-undef.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x; +//- elems +{ y: x = 1 } +//- vals +{ y: undefined } +//- body +assert.sameValue(x, 1); diff --git a/src/dstr-assignment/obj-prop-elem-init-evaluation.case b/src/dstr-assignment/obj-prop-elem-init-evaluation.case new file mode 100644 index 0000000000000000000000000000000000000000..47430121d25e240079c80b8a0193f997e1761041 --- /dev/null +++ b/src/dstr-assignment/obj-prop-elem-init-evaluation.case @@ -0,0 +1,23 @@ +// Copyright (C) 2015 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 +var flag1 = false; +var flag2 = false; +var 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`'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-arrow.js b/src/dstr-assignment/obj-prop-elem-init-fn-name-arrow.case similarity index 85% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-arrow.js rename to src/dstr-assignment/obj-prop-elem-init-fn-name-arrow.case index a089de2b73c70282a6b2eecbe60f19dfda8f2cb5..3cfff7b2a5ef2790d0434855947c927a2b323ccb 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-arrow.js +++ b/src/dstr-assignment/obj-prop-elem-init-fn-name-arrow.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ArrowFunction) +desc: Assignment of function `name` attribute (ArrowFunction) +template: default es6id: 12.14.5.4 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -18,10 +19,13 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var arrow; - -({ x: arrow = () => {} } = {}); - +//- elems +{ x: arrow = () => {} } +//- vals +{} +//- body assert.sameValue(arrow.name, 'arrow'); verifyNotEnumerable(arrow, 'name'); verifyNotWritable(arrow, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-class.js b/src/dstr-assignment/obj-prop-elem-init-fn-name-class.case similarity index 80% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-class.js rename to src/dstr-assignment/obj-prop-elem-init-fn-name-class.case index 43b0ddafb74fe79a7be5a01040de6f092b60176f..5652358615f105006493c757a0a64d5b2f22895f 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-class.js +++ b/src/dstr-assignment/obj-prop-elem-init-fn-name-class.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (ClassExpression) +desc: Assignment of function `name` attribute (ClassExpression) +template: default es6id: 12.14.5.4 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,12 +20,14 @@ includes: [propertyHelper.js] features: [class] ---*/ +//- setup var xCls, cls; - -({ x: xCls = class x {} } = {}); -({ x: cls = class {} } = {}); - -assert(xCls.name !== 'xCls'); +//- elems +{ x: xCls = class x {}, x: cls = class {} } +//- vals +{} +//- body +assert.notSameValue(xCls.name, 'xCls'); assert.sameValue(cls.name, 'cls'); verifyNotEnumerable(cls, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-cover.js b/src/dstr-assignment/obj-prop-elem-init-fn-name-cover.case similarity index 84% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-cover.js rename to src/dstr-assignment/obj-prop-elem-init-fn-name-cover.case index 5e4f473426eeae541918b4575edfd15a15666b7c..6e6afc4898551168fc981e78ecaa143195fa32ba 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-cover.js +++ b/src/dstr-assignment/obj-prop-elem-init-fn-name-cover.case @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Assignment of function `name` attribute (CoverParenthesizedExpression) +template: default es6id: 12.14.5.4 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,12 +20,14 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var xCover, cover; - -({ x: xCover = (0, function() {}) } = {}); -({ x: cover = (function() {}) } = {}); - -assert(xCover.name !== 'xCover'); +//- elems +{ x: xCover = (0, function() {}), x: cover = (function() {}) } +//- vals +{} +//- body +assert.notSameValue(xCover.name, 'xCover'); assert.sameValue(cover.name, 'cover'); verifyNotEnumerable(cover, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-fn.js b/src/dstr-assignment/obj-prop-elem-init-fn-name-fn.case similarity index 79% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-fn.js rename to src/dstr-assignment/obj-prop-elem-init-fn-name-fn.case index 79111de8caad845dfb22609cfe7b1a747abe59d4..7a2290ac602e1425b9e8ef28ee65c6745b8aa970 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-fn.js +++ b/src/dstr-assignment/obj-prop-elem-init-fn-name-fn.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (FunctionExpression) +desc: Assignment of function `name` attribute (FunctionExpression) +template: default es6id: 12.14.5.4 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -18,12 +19,14 @@ info: > includes: [propertyHelper.js] ---*/ +//- setup var xFn, fn; - -({ x: xFn = function x() {} } = {}); -({ x: fn = function() {} } = {}); - -assert(xFn.name !== 'xFn'); +//- elems +{ x: xFn = function x() {}, x: fn = function() {} } +//- vals +{} +//- body +assert.notSameValue(xFn.name, 'xFn'); assert.sameValue(fn.name, 'fn'); verifyNotEnumerable(fn, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-gen.js b/src/dstr-assignment/obj-prop-elem-init-fn-name-gen.case similarity index 79% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-gen.js rename to src/dstr-assignment/obj-prop-elem-init-fn-name-gen.case index c65a81683c8014e224fe538f13327b72ab0dfea3..292e8c615d1e03658aee94a1c795c38a54c834ad 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-fn-name-gen.js +++ b/src/dstr-assignment/obj-prop-elem-init-fn-name-gen.case @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Assignment of function `name` attribute (GeneratorExpression) +desc: Assignment of function `name` attribute (GeneratorExpression) +template: default es6id: 12.14.5.4 info: > AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt @@ -19,12 +20,14 @@ includes: [propertyHelper.js] features: [generators] ---*/ +//- setup var xGen, gen; - -({ x: xGen = function* x() {} } = {}); -({ x: gen = function*() {} } = {}); - -assert(xGen.name !== 'xGen'); +//- elems +{ x: xGen = function* x() {}, x: gen = function*() {} } +//- vals +{} +//- body +assert.notSameValue(xGen.name, 'xGen'); assert.sameValue(gen.name, 'gen'); verifyNotEnumerable(gen, 'name'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-in.js b/src/dstr-assignment/obj-prop-elem-init-in.case similarity index 68% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-in.js rename to src/dstr-assignment/obj-prop-elem-init-in.case index c8d724717db42a76f739cb3c489f52b8a3223657..c55ce6a828e2df61f93f79ba25a045cb784bafbf 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-in.js +++ b/src/dstr-assignment/obj-prop-elem-init-in.case @@ -2,15 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The Initializer in an AssignmentElement may be an `in` expression. +template: default es6id: 12.14.5 ---*/ -var value = {}; -var result, prop; - -result = { x: prop = 'x' in {} } = value; - -assert.sameValue(result, value); +//- setup +var prop; +//- elems +{ x: prop = 'x' in {} } +//- vals +{} +//- body assert.sameValue(prop, false); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-let.js b/src/dstr-assignment/obj-prop-elem-init-let.case similarity index 68% rename from test/language/expressions/assignment/destructuring/obj-id-init-let.js rename to src/dstr-assignment/obj-prop-elem-init-let.case index 0cae52ea93ea3c106cca42e626d392e2034b1f89..75186a9f5f0079b71704faecb289378a12bf34e6 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-init-let.js +++ b/src/dstr-assignment/obj-prop-elem-init-let.case @@ -2,15 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Value retrieval of Initializer obeys `let` semantics. +template: error es6id: 12.14.5.4 features: [let] ---*/ +//- setup var x; - -assert.throws(ReferenceError, function() { - ({ x = y } = {}); - let y; -}); +//- error +ReferenceError +//- elems +{ x: x = y } +//- vals +{} +//- teardown +let y; diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-expr.js b/src/dstr-assignment/obj-prop-elem-init-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-expr.js rename to src/dstr-assignment/obj-prop-elem-init-yield-expr.case index df69c2a2adc82363b46d84b94b88a265bcf247aa..9295443bcbb52be3e9b555b0351ba04003f65e3e 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-expr.js +++ b/src/dstr-assignment/obj-prop-elem-init-yield-expr.case @@ -2,31 +2,33 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 features: [generators] ---*/ -var value = {}; -var assignmentResult, iterationResult, iter, x; - +//- setup +var iterationResult, iter, x; iter = (function*() { - assignmentResult = { x: x = yield } = value; +//- elems +{ x: x = yield } +//- vals +{} +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(86); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 86); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-invalid.js b/src/dstr-assignment/obj-prop-elem-init-yield-ident-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-invalid.js rename to src/dstr-assignment/obj-prop-elem-init-yield-ident-invalid.case index 51f730df26c47659064feb875c217854084bcb2d..9c127af0ee7b003790ed54169d54fec5303f7a83 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-prop-elem-init-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -0, { x: x = yield } = {}; +//- elems +{ x: x = yield } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-valid.js b/src/dstr-assignment/obj-prop-elem-init-yield-ident-valid.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-valid.js rename to src/dstr-assignment/obj-prop-elem-init-yield-ident-valid.case index a197faea090c54ff746535598be1a3cd5c3317a4..6ebaf3718f469b17937718cafaa128fae3ecc73b 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-yield-ident-valid.js +++ b/src/dstr-assignment/obj-prop-elem-init-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = {}; +//- setup var yield = 4; var x; - -assignmentResult = { x: x = yield } = value; - -assert.sameValue(assignmentResult, value); +//- elems +{ x: x = yield } +//- vals +{} +//- body assert.sameValue(x, 4); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-expr.js b/src/dstr-assignment/obj-prop-elem-target-yield-expr.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-expr.js rename to src/dstr-assignment/obj-prop-elem-target-yield-expr.case index 644634311cab7145cb55e2e5d0d04d70211c0332..2cc4cc9e336eba46b39cf5536497cdbcae9efc7f 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-expr.js +++ b/src/dstr-assignment/obj-prop-elem-target-yield-expr.case @@ -2,32 +2,35 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 features: [generators] ---*/ -var value = { x: 23 }; +//- setup var x = {}; -var assignmentResult, iterationResult, iter; +var iterationResult, iter; iter = (function*() { - assignmentResult = { x: x[yield] } = value; +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x.prop, undefined); iterationResult = iter.next('prop'); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x.prop, 23); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-invalid.js b/src/dstr-assignment/obj-prop-elem-target-yield-ident-invalid.case similarity index 86% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-invalid.js rename to src/dstr-assignment/obj-prop-elem-target-yield-ident-invalid.case index c48c1289a76f3a1f7f78166afa02ef099240a225..75503db0e85cd0739a914aec8a1ec01376d21f94 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-prop-elem-target-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -var x = {}; -0, { x: x[yield] } = {}; +//- elems +{ x: x[yield] } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-valid.js b/src/dstr-assignment/obj-prop-elem-target-yield-ident-valid.case similarity index 78% rename from test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-valid.js rename to src/dstr-assignment/obj-prop-elem-target-yield-ident-valid.case index fe0d3aeb6fe29adc58a9a57945fdab673cb46ddd..597769a9f4e3839b5e32a0dffcbace2e72dd34bf 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-target-yield-ident-valid.js +++ b/src/dstr-assignment/obj-prop-elem-target-yield-ident-valid.case @@ -2,20 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = { x: 23 }; +//- setup var yield = 'prop'; var x = {}; -var result; - -result = { x: x[yield] } = value; - -assert.sameValue(result, value); +//- elems +{ x: x[yield] } +//- vals +{ x: 23 } +//- body assert.sameValue(x.prop, 23); diff --git a/src/dstr-assignment/obj-prop-identifier-resolution-first.case b/src/dstr-assignment/obj-prop-identifier-resolution-first.case new file mode 100644 index 0000000000000000000000000000000000000000..267b49e16be7aae6bf4dfe461c9c9df06992ee85 --- /dev/null +++ b/src/dstr-assignment/obj-prop-identifier-resolution-first.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x = null; +var y; +//- elems +{ a: x, y } +//- vals +{ a: 3 } +//- body +assert.sameValue(x, 3); diff --git a/src/dstr-assignment/obj-prop-identifier-resolution-last.case b/src/dstr-assignment/obj-prop-identifier-resolution-last.case new file mode 100644 index 0000000000000000000000000000000000000000..4209cdfbd30a6c557b3595183e56314bb9cbd4b0 --- /dev/null +++ b/src/dstr-assignment/obj-prop-identifier-resolution-last.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x = null; +var w; +//- elems +{ w, a: x } +//- vals +{ a: 4 } +//- body +assert.sameValue(x, 4); diff --git a/src/dstr-assignment/obj-prop-identifier-resolution-lone.case b/src/dstr-assignment/obj-prop-identifier-resolution-lone.case new file mode 100644 index 0000000000000000000000000000000000000000..ba2142a3d734f64b5bfb737a7bd229b751e23f73 --- /dev/null +++ b/src/dstr-assignment/obj-prop-identifier-resolution-lone.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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 +var x = null; +//- elems +{ a: x } +//- vals +{ a: 1 } +//- body +assert.sameValue(x, 1); diff --git a/src/dstr-assignment/obj-prop-identifier-resolution-middle.case b/src/dstr-assignment/obj-prop-identifier-resolution-middle.case new file mode 100644 index 0000000000000000000000000000000000000000..651969b1b7f3b9936b8f73d1087ac6b8ff7650c8 --- /dev/null +++ b/src/dstr-assignment/obj-prop-identifier-resolution-middle.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x = null; +var w, y; +//- elems +{ w, a: x, y } +//- vals +{ a: 5 } +//- body +assert.sameValue(x, 5); diff --git a/src/dstr-assignment/obj-prop-identifier-resolution-trlng.case b/src/dstr-assignment/obj-prop-identifier-resolution-trlng.case new file mode 100644 index 0000000000000000000000000000000000000000..6cf90f42baac1db94f6df8acfa33a58e8a614dca --- /dev/null +++ b/src/dstr-assignment/obj-prop-identifier-resolution-trlng.case @@ -0,0 +1,19 @@ +// Copyright (C) 2015 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 +var x = null; +//- elems +{ a: x, } +//- vals +{ a: 2 } +//- body +assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-name-evaluation-error.js b/src/dstr-assignment/obj-prop-name-evaluation-error.case similarity index 75% rename from test/language/expressions/assignment/destructuring/obj-prop-name-evaluation-error.js rename to src/dstr-assignment/obj-prop-name-evaluation-error.case index 854c6b9c59a516d9cd3490cb920eacf8cf0c57ad..16861461ba55a5451a3e1be65450fe73a83cf155 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-name-evaluation-error.js +++ b/src/dstr-assignment/obj-prop-name-evaluation-error.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Any error raised as a result of evaluating PropertyName should be forwarded to the runtime. +template: error es6id: 12.14.5.2 ---*/ +//- setup var a, x; - -assert.throws(TypeError, function() { - ({ [a.b]: x } = {}); -}); +//- error +TypeError +//- elems +{ [a.b]: x } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-prop-name-evaluation.js b/src/dstr-assignment/obj-prop-name-evaluation.case similarity index 69% rename from test/language/expressions/assignment/destructuring/obj-prop-name-evaluation.js rename to src/dstr-assignment/obj-prop-name-evaluation.case index 52d4b6ef69a33c937207075b058770e22355edbc..2316d6d09c5f20b6fb8f45cf57040288335c4ff3 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-name-evaluation.js +++ b/src/dstr-assignment/obj-prop-name-evaluation.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > PropertyName of an AssignmentProperty may be a ComputedPropertyName. +template: default es6id: 12.14.5.2 ---*/ -var value = { x: 1, xy: 23, y: 2 }; -var result, x, y, xy; - -result = { ['x' + 'y']: x } = value; - -assert.sameValue(result, value); +//- setup +var 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); diff --git a/src/dstr-assignment/obj-prop-nested-array-invalid.case b/src/dstr-assignment/obj-prop-nested-array-invalid.case new file mode 100644 index 0000000000000000000000000000000000000000..b4321822d347faef8031e7c3d649e043e6f4782b --- /dev/null +++ b/src/dstr-assignment/obj-prop-nested-array-invalid.case @@ -0,0 +1,18 @@ +// Copyright (C) 2015 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: syntax +es6id: 12.14.5.1 +negative: SyntaxError +---*/ + +//- elems +{ x: [(x, y)] } +//- vals +{ x: [] } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-null.js b/src/dstr-assignment/obj-prop-nested-array-null.case similarity index 75% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-null.js rename to src/dstr-assignment/obj-prop-nested-array-null.case index 7a40d1fb78d223c0372223c3d2f340502e6c5973..e893e8aa050f1b95fe751e778543c2126729c4bb 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-null.js +++ b/src/dstr-assignment/obj-prop-nested-array-null.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is `null`, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: [ x ] } = { x: null }); -}); +//- error +TypeError +//- elems +{ x: [ x ] } +//- vals +{ x: null } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined-own.js b/src/dstr-assignment/obj-prop-nested-array-undefined-own.case similarity index 74% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined-own.js rename to src/dstr-assignment/obj-prop-nested-array-undefined-own.case index e1f0dd63c737228cdc8bdc375a4b437b557a99e4..415c4d99974bdafe71d7ea3421ac42704f70e7c7 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined-own.js +++ b/src/dstr-assignment/obj-prop-nested-array-undefined-own.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is `undefined`, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: [ x ] } = { x: undefined }); -}); +//- error +TypeError +//- elems +{ x: [ x ] } +//- vals +{ x: undefined } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined.js b/src/dstr-assignment/obj-prop-nested-array-undefined.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined.js rename to src/dstr-assignment/obj-prop-nested-array-undefined.case index 95554b916584f7615c04a6f87cd71d159f637f19..1e4230ae53b4571207522d56e47c76a050b719c1 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-undefined.js +++ b/src/dstr-assignment/obj-prop-nested-array-undefined.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an array literal and the value is not defined, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: [ x ] } = {}); -}); +//- error +TypeError +//- elems +{ x: [ x ] } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-expr.js b/src/dstr-assignment/obj-prop-nested-array-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-expr.js rename to src/dstr-assignment/obj-prop-nested-array-yield-expr.case index 4e1e142e2393ef91ad3f17357bca7aa0bfcbbeeb..fba8a40ada69b07dde019a0bcf9040672de1e0ff 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-expr.js +++ b/src/dstr-assignment/obj-prop-nested-array-yield-expr.case @@ -2,31 +2,34 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 features: [generators] ---*/ -var value = { x: [] }; -var assignmentResult, iterationResult, iter, x; +//- setup +var iterationResult, iter, x; iter = (function*() { - assignmentResult = { x: [x = yield] } = value; +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult = undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(24601); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 24601); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-invalid.js b/src/dstr-assignment/obj-prop-nested-array-yield-ident-invalid.case similarity index 84% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-invalid.js rename to src/dstr-assignment/obj-prop-nested-array-yield-ident-invalid.case index 29a8e9c6c4e19ae1250d327504032b311ef70aad..addafc3b40ecbbdf81c4724ad9c80256586fae4e 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-prop-nested-array-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -0, { x: [x = yield] } = { x: [] }; +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-valid.js b/src/dstr-assignment/obj-prop-nested-array-yield-ident-valid.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-valid.js rename to src/dstr-assignment/obj-prop-nested-array-yield-ident-valid.case index 83df76722c48c0bad7174fa805561bea50c93525..19b82bbe5abc82576c2f80a57cebe546a29c8226 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-yield-ident-valid.js +++ b/src/dstr-assignment/obj-prop-nested-array-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = { x: [] }; +//- setup var yield = 22; -var result, x; - -result = { x: [x = yield] } = value; - -assert.sameValue(result, value); +var x; +//- elems +{ x: [x = yield] } +//- vals +{ x: [] } +//- body assert.sameValue(x, 22); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array.js b/src/dstr-assignment/obj-prop-nested-array.case similarity index 75% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-array.js rename to src/dstr-assignment/obj-prop-nested-array.case index a28cc299c804b7fbb4da2e2590a36057fe044d7d..3aabe634ccba8611573bf7f1f9d2014b5a88e9aa 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array.js +++ b/src/dstr-assignment/obj-prop-nested-array.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 ---*/ -var value = { x: [321] }; -var result, y; - -result = { x: [y] } = value; - -assert.sameValue(result, value); +//- setup +var y; +//- elems +{ x: [y] } +//- vals +{ x: [321] } +//- body assert.sameValue(y, 321); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-invalid.js b/src/dstr-assignment/obj-prop-nested-obj-invalid.case similarity index 85% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-invalid.js rename to src/dstr-assignment/obj-prop-nested-obj-invalid.case index e1388ff867f92e14342941d17a32661805786032..9bf46e92cd850aa849f1d363e1346f4b76a80d49 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-invalid.js +++ b/src/dstr-assignment/obj-prop-nested-obj-invalid.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.1 negative: SyntaxError ---*/ -({ x: { get x() {} } } = { x: {} }); +//- elems +{ x: { get x() {} } } +//- vals +{ x: {} } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-null.js b/src/dstr-assignment/obj-prop-nested-obj-null.case similarity index 75% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-null.js rename to src/dstr-assignment/obj-prop-nested-obj-null.case index 7806305a64792bc5a732f8302b51743f05621620..d0f88aad7e5c45570ddf8c3cbcff4134f68835f6 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-null.js +++ b/src/dstr-assignment/obj-prop-nested-obj-null.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is `null`, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: { x } } = { x: null }); -}); +//- error +TypeError +//- elems +{ x: { x } } +//- vals +{ x: null } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined-own.js b/src/dstr-assignment/obj-prop-nested-obj-undefined-own.case similarity index 74% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined-own.js rename to src/dstr-assignment/obj-prop-nested-obj-undefined-own.case index 771e90e4ec8995bc6bad7aea5faaabcc7c997cfd..506879adddebe547e597e35a6b62e19488af0ce5 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined-own.js +++ b/src/dstr-assignment/obj-prop-nested-obj-undefined-own.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is `undefined`, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: { x } } = { x: undefined }); -}); +//- error +TypeError +//- elems +{ x: { x } } +//- vals +{ x: undefined } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined.js b/src/dstr-assignment/obj-prop-nested-obj-undefined.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined.js rename to src/dstr-assignment/obj-prop-nested-obj-undefined.case index ac0ff673a0aabe3da65ee62c005e05484d1c806d..742d2d99d9b73fe00dd9683484e7aa22ad18ecd1 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-undefined.js +++ b/src/dstr-assignment/obj-prop-nested-obj-undefined.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > When DestructuringAssignmentTarget is an object literal and the value is not defined, a TypeError should be thrown. +template: error es6id: 12.14.5.4 ---*/ +//- setup var x; - -assert.throws(TypeError, function() { - ({ x: { x } } = {}); -}); +//- error +TypeError +//- elems +{ x: { x } } +//- vals +{} diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-expr.js b/src/dstr-assignment/obj-prop-nested-obj-yield-expr.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-expr.js rename to src/dstr-assignment/obj-prop-nested-obj-yield-expr.case index 3d89a89736fa3c457831817d38659f885699e49f..34bb01f8cc97d8312423da91aec632c5ebc9d2e9 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-expr.js +++ b/src/dstr-assignment/obj-prop-nested-obj-yield-expr.case @@ -2,31 +2,34 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 features: [generators] ---*/ -var value = { x: {} }; -var assignmentResult, iterationResult, iter, x; +//- setup +var iterationResult, iter, x = undefined; iter = (function*() { - assignmentResult = { x: { x = yield } } = value; +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- teardown }()); iterationResult = iter.next(); -assert.sameValue(assignmentResult, undefined); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, false); assert.sameValue(x, undefined); iterationResult = iter.next(4); -assert.sameValue(assignmentResult, value); assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.done, true); assert.sameValue(x, 4); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-invalid.js b/src/dstr-assignment/obj-prop-nested-obj-yield-ident-invalid.case similarity index 84% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-invalid.js rename to src/dstr-assignment/obj-prop-nested-obj-yield-ident-invalid.case index 3a4b44df7de4a6b4f8ed6adfa8d5834c35e9120e..c37458e46d2882c4fd381cc0c67e5fb13029b5b4 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-invalid.js +++ b/src/dstr-assignment/obj-prop-nested-obj-yield-ident-invalid.case @@ -2,14 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: syntax es6id: 12.14.5.4 flags: [onlyStrict] negative: SyntaxError ---*/ -var x; -0, { x: { x = yield } } = { x: {} }; +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-valid.js b/src/dstr-assignment/obj-prop-nested-obj-yield-ident-valid.case similarity index 79% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-valid.js rename to src/dstr-assignment/obj-prop-nested-obj-yield-ident-valid.case index 7261d722e17bddca2d7861ab97c95539948b5422..5e30d0cb26755f2d33984080eb468bd564337951 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj-yield-ident-valid.js +++ b/src/dstr-assignment/obj-prop-nested-obj-yield-ident-valid.case @@ -2,19 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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: default es6id: 12.14.5.4 flags: [noStrict] ---*/ -var value = { x: {} }; +//- setup var yield = 2; var result, x; - -result = { x: { x = yield } } = value; - -assert.sameValue(result, value); +//- elems +{ x: { x = yield } } +//- vals +{ x: {} } +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj.js b/src/dstr-assignment/obj-prop-nested-obj.case similarity index 77% rename from test/language/expressions/assignment/destructuring/obj-prop-nested-obj.js rename to src/dstr-assignment/obj-prop-nested-obj.case index a47fdaccb21504a62b0448b5e7f5f3f90bbacd02..2391e49b38f36eeed6478322c29b5a89fbd5a35e 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-obj.js +++ b/src/dstr-assignment/obj-prop-nested-obj.case @@ -2,17 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 ---*/ -var value = { x: { y: 2 } }; +//- setup var result, y; - -result = { x: { y } } = value; - -assert.sameValue(result, value); +//- elems +{ x: { y } } +//- vals +{ x: { y: 2 } } +//- body assert.sameValue(y, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-const.js b/src/dstr-assignment/obj-prop-put-const.case similarity index 73% rename from test/language/expressions/assignment/destructuring/obj-prop-put-const.js rename to src/dstr-assignment/obj-prop-put-const.case index d17289a0aca35f025c4aa4a6aa28665b283c7aa0..fd347659338465acce3d37cf16eb96a6a59c93ad 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-const.js +++ b/src/dstr-assignment/obj-prop-put-const.case @@ -2,14 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `const` semantics. +template: error es6id: 12.14.5.4 features: [const] ---*/ +//- setup const c = 1; - -assert.throws(TypeError, function() { - ({ a: c } = { a: 2 }); -}); +//- error +TypeError +//- elems +{ a: c } +//- vals +{ a: 2 } diff --git a/test/language/expressions/assignment/destructuring/obj-id-put-let.js b/src/dstr-assignment/obj-prop-put-let.case similarity index 70% rename from test/language/expressions/assignment/destructuring/obj-id-put-let.js rename to src/dstr-assignment/obj-prop-put-let.case index 28c1145de0d567e001067c92f2198767a6c5a7e9..358c9d0055d6a6cf28f9b1328fdc1f88c612dc07 100644 --- a/test/language/expressions/assignment/destructuring/obj-id-put-let.js +++ b/src/dstr-assignment/obj-prop-put-let.case @@ -2,13 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The assignment target should obey `let` semantics. +template: error es6id: 12.14.5.4 features: [let] ---*/ -assert.throws(ReferenceError, function() { - ({ x } = {}); - let x; -}); +//- error +ReferenceError +//- elems +{ a: x } +//- vals +{} +//- teardown +let x; diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-order.js b/src/dstr-assignment/obj-prop-put-order.case similarity index 69% rename from test/language/expressions/assignment/destructuring/obj-prop-put-order.js rename to src/dstr-assignment/obj-prop-put-order.case index e6e360f8789287afe04c657be7adfa0229cf5989..6f4ca4faf61065db3279e8605cc2f1d1e35031d7 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-order.js +++ b/src/dstr-assignment/obj-prop-put-order.case @@ -2,16 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The AssignmentElements in an AssignmentElementList are evaluated in left- to-right order. +template: default es6id: 12.14.5.4 ---*/ -var value = { a: 2, z: 1 }; -var x, result; - -result = { z: x, a: x } = value; - -assert.sameValue(result, value); +//- setup +var x; +//- elems +{ z: x, a: x } +//- vals +{ a: 2, z: 1 } +//- body assert.sameValue(x, 2); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-no-get.js b/src/dstr-assignment/obj-prop-put-prop-ref-no-get.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-no-get.js rename to src/dstr-assignment/obj-prop-put-prop-ref-no-get.case index 9f036e6c7d599e8cd955fb5a692d97e7e5a7e91e..2b5b83ec5f9bafdbe38699d9190ee68069cb7610 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-no-get.js +++ b/src/dstr-assignment/obj-prop-put-prop-ref-no-get.case @@ -2,15 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. +template: default es6id: 12.14.5.4 ---*/ -var value = { a: 23 }; -var x, setValue, result; -x = { +//- setup +var setValue; +var x = { get y() { $ERROR('The property should not be accessed.'); }, @@ -18,8 +19,9 @@ x = { setValue = val; } }; - -result = { a: x.y } = value; - -assert.sameValue(result, value); +//- elems +{ a: x.y } +//- vals +{ a: 23 } +//- body assert.sameValue(setValue, 23); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-user-err.js b/src/dstr-assignment/obj-prop-put-prop-ref-user-err.case similarity index 75% rename from test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-user-err.js rename to src/dstr-assignment/obj-prop-put-prop-ref-user-err.case index dafa8026c0d55a99c6b147d359fbac48cf9bac8a..1e119134f7a4ffc34d3b40f9732380c4ba1b7c93 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref-user-err.js +++ b/src/dstr-assignment/obj-prop-put-prop-ref-user-err.case @@ -2,19 +2,22 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > Any error raised as a result of setting the value should be forwarded to the runtime. +template: error es6id: 12.14.5.4 ---*/ -var value = { a: 23 }; +//- setup var x = { set y(val) { throw new Test262Error(); } }; - -assert.throws(Test262Error, function() { - ({ a: x.y } = value); -}); +//- error +Test262Error +//- elems +{ a: x.y } +//- vals +{ a: 23 } diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref.js b/src/dstr-assignment/obj-prop-put-prop-ref.case similarity index 72% rename from test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref.js rename to src/dstr-assignment/obj-prop-put-prop-ref.case index 163cc9ff8c6acbac6b4809e144ffedcfcd3dcfc8..6a78d80ff816c4e57c1564cc18e6c43855c291f3 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-prop-ref.js +++ b/src/dstr-assignment/obj-prop-put-prop-ref.case @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. +template: default es6id: 12.14.5.4 ---*/ -var value = { xy: 4 }; +//- setup var x = {}; -var result; - -result = { xy: x.y } = value; - -assert.sameValue(result, value); +//- elems +{ xy: x.y } +//- vals +{ xy: 4 } +//- body assert.sameValue(x.y, 4); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-no-strict.js b/src/dstr-assignment/obj-prop-put-unresolvable-no-strict.case similarity index 81% rename from test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-no-strict.js rename to src/dstr-assignment/obj-prop-put-unresolvable-no-strict.case index 0ed86512281233b14e317a213ab32391f0d4606e..c2dff5c9043c1e76e5327be87f4fb8c05e1580e5 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-no-strict.js +++ b/src/dstr-assignment/obj-prop-put-unresolvable-no-strict.case @@ -2,15 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +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 { - ({ x: unresolvable } = {}); +//- elems +{ x: unresolvable } +//- vals +{} +//- teardown } assert.sameValue(unresolvable, undefined); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-strict.js b/src/dstr-assignment/obj-prop-put-unresolvable-strict.case similarity index 76% rename from test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-strict.js rename to src/dstr-assignment/obj-prop-put-unresolvable-strict.case index f75a6927c5885cf3d32a7c0f8eb235cf881ed7ec..52cbdd565dd26564305e08d00320ed04eb374463 100644 --- a/test/language/expressions/assignment/destructuring/obj-prop-put-unresolvable-strict.js +++ b/src/dstr-assignment/obj-prop-put-unresolvable-strict.case @@ -2,13 +2,17 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > +desc: > In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. +template: error es6id: 12.14.5.4 flags: [onlyStrict] ---*/ -assert.throws(ReferenceError, function() { - ({ x: unresolvable } = {}); -}); +//- error +ReferenceError +//- elems +{ x: unresolvable } +//- vals +{} diff --git a/src/dstr-assignment/syntax/assignment-expr.template b/src/dstr-assignment/syntax/assignment-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..a93edd3e645593908b73035125ef343257bca0ca --- /dev/null +++ b/src/dstr-assignment/syntax/assignment-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/assignment/dstr- +name: > + AssignmentExpression +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +0, /*{ elems }*/ = /*{ vals }*/; diff --git a/src/dstr-assignment/syntax/for-in.template b/src/dstr-assignment/syntax/for-in.template new file mode 100644 index 0000000000000000000000000000000000000000..279b319960176bc2d648acd34903619fc039bd78 --- /dev/null +++ b/src/dstr-assignment/syntax/for-in.template @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-in/dstr- +name: > + For..in statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +info: | + IterationStatement : + for ( 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 + + [...] + 4. 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. + [...] +---*/ + +for (/*{ elems }*/ in [/*{ vals }*/]) ; diff --git a/src/dstr-assignment/syntax/for-of.template b/src/dstr-assignment/syntax/for-of.template new file mode 100644 index 0000000000000000000000000000000000000000..430550dd3cf5d798ccbafd146cf90b0e5e5e36cd --- /dev/null +++ b/src/dstr-assignment/syntax/for-of.template @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-of/dstr- +name: > + For..of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +info: | + IterationStatement : + for ( 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 + + [...] + 4. 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. + [...] +---*/ + +for (/*{ elems }*/ of [/*{ vals }*/]) ; diff --git a/test/language/expressions/assignment/destructuring/array-elem-elision.js b/test/language/expressions/assignment/destructuring/array-elem-elision.js deleted file mode 100644 index dd7c6dd6128555777191cfb0abcb67f764e37c0e..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-elem-elision.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - ArrayAssignmentPattern may include elisions at any position in a - AssignmentElementList that does not contain an AssignmentRestElement. -es6id: 12.14.5 ----*/ - -var value = [1, 2, 3, 4, 5, 6]; -var x, y; -var result; - -result = [, x, , y, ,] = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2); -assert.sameValue(y, 4); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-assignment.js b/test/language/expressions/assignment/destructuring/array-elem-init-assignment.js deleted file mode 100644 index 3eea1f6863282f33063d701cd698fdae5a1ee935..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-elem-init-assignment.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - If the Initializer is present and v is undefined, the Initializer should be - evaluated and the result assigned to the target reference. -es6id: 12.14.5.3 ----*/ - -var result, value, x; - -value = []; -result = [ x = 10 ] = value; - -assert.sameValue(result, value); -assert.sameValue(x, 10, 'no element at index'); - -value = [2]; -result = [ x = 11 ] = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2, 'element at index (truthy value)'); - -value = [ null ]; -result = [ x = 12 ] = value; - -assert.sameValue(result, value); -assert.sameValue(x, null, 'element at index (`null`)'); - -value = [ undefined ]; -result = [ x = 13 ] = value; - -assert.sameValue(result, value); -assert.sameValue(x, 13, 'element at index (`undefined`)'); - -value = [ , ]; -result = [ x = 14 ] = value; - -assert.sameValue(result, value); -assert.sameValue(x, 14, 'element at index (sparse array)'); diff --git a/test/language/expressions/assignment/destructuring/array-elem-init-evaluation.js b/test/language/expressions/assignment/destructuring/array-elem-init-evaluation.js deleted file mode 100644 index 0e5198eeac048de52b6f29e772600f76d5d6d9ab..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-elem-init-evaluation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The Initializer should only be evaluated if v is undefined. -es6id: 12.14.5.3 ----*/ - -var result, value, x, flag; - -value = []; -flag = false; -result = [ x = flag = true ] = value; -assert.sameValue(result, value); -assert.sameValue(x, true); -assert.sameValue(flag, true); - -value = [14]; -flag = false; -result = [ x = flag = true ] = value; -assert.sameValue(result, value); -assert.sameValue(x, 14); -assert.sameValue(flag, false); diff --git a/test/language/expressions/assignment/destructuring/array-elision.js b/test/language/expressions/assignment/destructuring/array-elision.js deleted file mode 100644 index 8933cb5a147735902ac1805a7ba66111151be17c..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-elision.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - An ArrayAssignmentPattern containing only Elisions requires iterable values - and throws for other values. -es6id: 12.14.5.2 ----*/ - -var value, result; - -assert.throws(TypeError, function() { - [,] = undefined; -}); - -assert.throws(TypeError, function() { - [,] = null; -}); - -assert.throws(TypeError, function() { - [,] = true; -}); - -assert.throws(TypeError, function() { - [,] = 1; -}); - -result = [,] = 'string literal'; - -assert.sameValue(result, 'string literal'); - -assert.throws(TypeError, function() { - [,] = Symbol('s'); -}); - -value = []; -result = [,] = value; - -assert.sameValue(result, value); diff --git a/test/language/expressions/assignment/destructuring/array-empty.js b/test/language/expressions/assignment/destructuring/array-empty.js deleted file mode 100644 index 524f73f8fdbb6d7bc3fb0c42dc0b0ad70663e3ec..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-empty.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - An ArrayAssignmentPattern without an AssignmentElementList requires - iterable values and throws for other values. -es6id: 12.14.5.2 ----*/ - -var value, result; - -assert.throws(TypeError, function() { - [] = undefined; -}); - -assert.throws(TypeError, function() { - [] = null; -}); - -assert.throws(TypeError, function() { - [] = true; -}); - -assert.throws(TypeError, function() { - [] = 1; -}); - -result = [] = 'string literal'; - -assert.sameValue(result, 'string literal'); - -assert.throws(TypeError, function() { - [] = Symbol('s'); -}); - -value = []; -result = [] = value; - -assert.sameValue(result, value); diff --git a/test/language/expressions/assignment/destructuring/array-iteration.js b/test/language/expressions/assignment/destructuring/array-iteration.js deleted file mode 100644 index bbaa568a87fb024737d6c206031235b95e9570e0..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/array-iteration.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - Value iteration only proceeds for the number of elements in the - ArrayAssignmentPattern. -es6id: 12.14.5.3 -features: [generators] ----*/ - -var count, iter, result; -var g = function*() { - count += 1; - yield; - count += 1; - yield; - count += 1; -} - -count = 0; -iter = g(); -result = [] = iter; - -assert.sameValue(result, iter); -assert.sameValue(count, 0); - -iter = g(); -result = [,] = iter; - -assert.sameValue(result, iter); -assert.sameValue(count, 1); - -count = 0; -iter = g(); -result = [,,] = iter; - -assert.sameValue(result, iter); -assert.sameValue(count, 2); - -count = 0; -iter = g(); -result = [,,,] = iter; - -assert.sameValue(result, iter); -assert.sameValue(count, 3); - -count = 0; -iter = g(); -result = [,,,,] = iter; - -assert.sameValue(result, iter); -assert.sameValue(count, 3); diff --git a/test/language/expressions/assignment/destructuring/obj-id-identifier-resolution.js b/test/language/expressions/assignment/destructuring/obj-id-identifier-resolution.js deleted file mode 100644 index ff3dd5a201ed02b9f648685d622feb6217473dc6..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-id-identifier-resolution.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - Evaluation of DestructuringAssignmentTarget. -es6id: 12.14.5.4 ----*/ - -var result, value, w, x, y; - -x = null; -value = { x: 1 }; -result = { x } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1); - -x = null; -value = { x: 2 }; -result = { x, } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2); - -x = null; -value = { x: 3 }; -result = { x, y } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 3); - -x = null; -value = { x: 4 }; -result = { w, x } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 4); - -x = null; -value = { x: 5 }; -result = { w, x, y } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 5); diff --git a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-valid.js b/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-valid.js deleted file mode 100644 index 4d4b5c83634b8312099de95e62ec62e422992f13..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-id-identifier-yield-ident-valid.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - `yield` is a valid IdentifierReference in an AssignmentProperty outside of - strict mode and generator functions. -es6id: 12.14.5 -flags: [noStrict] ----*/ - -var value = { yield: 3 }; -var result, yield; - -result = { yield } = value; - -assert.sameValue(result, value); -assert.sameValue(yield, 3); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-assignment.js b/test/language/expressions/assignment/destructuring/obj-id-init-assignment.js deleted file mode 100644 index 5e9da802e441d974738d7b93404be4f133a3f0dd..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-id-init-assignment.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - If the Initializer is present and v is undefined, the Initializer should be - evaluated and the result assigned to the target reference. -es6id: 12.14.5.4 ----*/ - -var result, value, x; - -value = {}; -result = { x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1, 'no property defined'); - -value = { x: 2 }; -result = { x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2, 'own property defined (truthy value)'); - -value = { x: null }; -result = { x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, null, 'own property defined (`null`)'); - -value = { x: undefined }; -result = { x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1, 'own property defined (`undefined`)'); diff --git a/test/language/expressions/assignment/destructuring/obj-id-init-evaluation.js b/test/language/expressions/assignment/destructuring/obj-id-init-evaluation.js deleted file mode 100644 index af03125bd2fd49394c2449a105f421cc0c868ad1..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-id-init-evaluation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The Initializer should only be evaluated if v is undefined. -es6id: 12.14.5.4 ----*/ - -var result, value, x, flag; - -value = {}; -flag = false; -result = { x = flag = true } = value; -assert.sameValue(result, value); -assert.sameValue(x, true); -assert.sameValue(flag, true); - -value = { x: 1 }; -flag = false; -result = { x = flag = true } = value; -assert.sameValue(result, value); -assert.sameValue(x, 1); -assert.sameValue(flag, false); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-assignment.js b/test/language/expressions/assignment/destructuring/obj-prop-elem-init-assignment.js deleted file mode 100644 index 85c013feaef9ba2ef0204cb486f4000ffe7ae040..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-assignment.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - If the Initializer is present and v is undefined, the Initializer should be - evaluated and the result assigned to the target reference. -es6id: 12.14.5.4 ----*/ - -var result, value, x; - -value = {}; -result = { y: x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1, 'no property defined'); - -value = { y: 2 }; -result = { y: x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2, 'own property defined (truthy value)'); - -value = { y: null }; -result = { y: x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, null, 'own property defined (`null`)'); - -value = { y: undefined }; -result = { y: x = 1 } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1, 'own property defined (`undefined`)'); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-evaluation.js b/test/language/expressions/assignment/destructuring/obj-prop-elem-init-evaluation.js deleted file mode 100644 index efd1237e31855db779effe4f5a4ace059d63e8dc..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-prop-elem-init-evaluation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The Initializer should only be evaluated if v is undefined. -es6id: 12.14.5.4 ----*/ - -var result, value, x, flag; - -value = {}; -flag = false; -result = { x: x = flag = true } = value; -assert.sameValue(result, value); -assert.sameValue(x, true); -assert.sameValue(flag, true); - -value = { y: 1 }; -flag = false; -result = { y: x = flag = true } = value; -assert.sameValue(result, value); -assert.sameValue(x, 1); -assert.sameValue(flag, false); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-identifier-resolution.js b/test/language/expressions/assignment/destructuring/obj-prop-identifier-resolution.js deleted file mode 100644 index 2798828162fbc754be98557b43587a560b13b43e..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-prop-identifier-resolution.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - Evaluation of DestructuringAssignmentTarget. -es6id: 12.14.5.4 ----*/ - -var result, value, w, x, y; - -x = null; -value = { a: 1 }; -result = { a: x } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 1); - -x = null; -value = { a: 2 }; -result = { a: x, } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 2); - -x = null; -value = { a: 3 }; -result = { a: x, y } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 3); - -x = null; -value = { a: 4 }; -result = { w, a: x } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 4); - -x = null; -value = { a: 5 }; -result = { w, a: x, y } = value; - -assert.sameValue(result, value); -assert.sameValue(x, 5); diff --git a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-invalid.js b/test/language/expressions/assignment/destructuring/obj-prop-nested-array-invalid.js deleted file mode 100644 index 011b8291df21378fedd2a66b443f7644ec14b634..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/obj-prop-nested-array-invalid.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - 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. -es6id: 12.14.5.1 -negative: SyntaxError ----*/ - -var x, y; - -({ x: [(x, y)] } = { x: [] }); diff --git a/test/language/expressions/assignment/destructuring/object-empty.js b/test/language/expressions/assignment/destructuring/object-empty.js deleted file mode 100644 index 9658156eb7bb8b6e170f008650ec5347feabf1ed..0000000000000000000000000000000000000000 --- a/test/language/expressions/assignment/destructuring/object-empty.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - An ObjectAssignmentPattern without an AssignmentPropertyList requires - object-coercible values and throws for other values. -es6id: 12.14.5.2 ----*/ - -var value, result; - -assert.throws(TypeError, function() { - 0, {} = undefined; -}); - -assert.throws(TypeError, function() { - 0, {} = null; -}); - -result = {} = true; - -assert.sameValue(result, true); - -result = {} = 1; - -assert.sameValue(result, 1); - -result = {} = 'string literal'; - -assert.sameValue(result, 'string literal'); - -value = Symbol('s'); -result = {} = value; - -assert.sameValue(result, value); - -value = {}; -result = {} = value; - -assert.sameValue(result, value);