Re-format destructuring assignment tests

Utilize the test generation tool to increase coverage of destructuring
assignment semantics. Previously, only destructuring assignment in the
AssignmentExpression position was tested. With this change applied, the
same tests will assert expected behavior for destructuring assignment in
`for..of` statements, as well.

A limited number of tests are applied to the `for..in` statement as
well, but due to the iteration protocol observed by that statement, many
destructuring tests are not relevant, and others cannot be automatically
generated from this format.
This commit is contained in:
Mike Pennisi 2016-05-20 18:58:23 -04:00
parent 56b988883e
commit c24a206511
265 changed files with 2737 additions and 1505 deletions

View File

@ -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);

View File

@ -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);

View File

@ -2,7 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 es6id: 12.14.5.3
info: > info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
@ -18,10 +19,13 @@ info: >
includes: [propertyHelper.js] includes: [propertyHelper.js]
---*/ ---*/
//- setup
var arrow; var arrow;
//- elems
[ arrow = () => {} ] = []; [ arrow = () => {} ]
//- vals
[]
//- body
assert.sameValue(arrow.name, 'arrow'); assert.sameValue(arrow.name, 'arrow');
verifyNotEnumerable(arrow, 'name'); verifyNotEnumerable(arrow, 'name');
verifyNotWritable(arrow, 'name'); verifyNotWritable(arrow, 'name');

View File

@ -2,7 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 es6id: 12.14.5.3
info: > info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
@ -19,11 +20,13 @@ includes: [propertyHelper.js]
features: [class] features: [class]
---*/ ---*/
//- setup
var xCls, cls; var xCls, cls;
//- elems
[ xCls = class x {} ] = [];; [ xCls = class x {},cls = class {} ]
[ cls = class {} ] = []; //- vals
[]
//- body
assert(xCls.name !== 'xCls'); assert(xCls.name !== 'xCls');
assert.sameValue(cls.name, 'cls'); assert.sameValue(cls.name, 'cls');

View File

@ -2,8 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Assignment of function `name` attribute (CoverParenthesizedExpression) Assignment of function `name` attribute (CoverParenthesizedExpression)
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
info: > info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
@ -19,11 +20,13 @@ info: >
includes: [propertyHelper.js] includes: [propertyHelper.js]
---*/ ---*/
//- setup
var xCover, cover; var xCover, cover;
//- elems
[ xCover = (0, function() {}) ] = []; [ xCover = (0, function() {}), cover = (function() {}) ]
[ cover = (function() {}) ] = []; //- vals
[]
//- body
assert(xCover.name !== 'xCover'); assert(xCover.name !== 'xCover');
assert.sameValue(cover.name, 'cover'); assert.sameValue(cover.name, 'cover');

View File

@ -2,7 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 es6id: 12.14.5.3
info: > info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
@ -19,11 +20,13 @@ includes: [propertyHelper.js]
features: [class] features: [class]
---*/ ---*/
//- setup
var xFn, fn; var xFn, fn;
//- elems
[ xFn = function x() {} ] = [];; [ xFn = function x() {}, fn = function() {} ]
[ fn = function() {} ] = []; //- vals
[]
//- body
assert(xFn.name !== 'xFn'); assert(xFn.name !== 'xFn');
assert.sameValue(fn.name, 'fn'); assert.sameValue(fn.name, 'fn');

View File

@ -2,7 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 es6id: 12.14.5.3
info: > info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
@ -19,12 +20,14 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
//- setup
var xGen, gen; var xGen, gen;
//- elems
[ xGen = function* x() {} ] = []; [ xGen = function* x() {}, gen = function*() {} ]
[ gen = function*() {} ] = [];; //- vals
[]
assert(xGen.name !== 'xGen'); //- body
assert.notSameValue(xGen.name, 'xGen');
assert.sameValue(gen.name, 'gen'); assert.sameValue(gen.name, 'gen');
verifyNotEnumerable(gen, 'name'); verifyNotEnumerable(gen, 'name');

View File

@ -2,15 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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. The Initializer in an AssignmentElement may be an `in` expression.
template: default
es6id: 12.14.5 es6id: 12.14.5
---*/ ---*/
var value = []; //- setup
var result, x; var x;
//- elems
result = [ x = 'x' in {} ] = value; [ x = 'x' in {} ]
//- vals
assert.sameValue(result, value); []
//- body
assert.sameValue(x, false); assert.sameValue(x, false);

View File

@ -2,15 +2,20 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Value retrieval of Initializer obeys `let` semantics. Value retrieval of Initializer obeys `let` semantics.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
features: [let] features: [let]
---*/ ---*/
//- error
ReferenceError
//- setup
var x; var x;
//- elems
assert.throws(ReferenceError, function() { [ x = y ]
[ x = y ] = []; //- vals
[]
//- teardown
let y; let y;
});

View File

@ -2,18 +2,20 @@
// This code is governed by the BSD license found in the LICENSE file. // 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. Initializer values should be assigned in left-to-right order.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = []; //- setup
var x = 0; var x = 0;
var a, b, result; var a, b;
//- elems
result = [ a = x += 1, b = x *= 2 ] = value; [ a = x += 1, b = x *= 2 ]
//- vals
assert.sameValue(result, value); []
//- body
assert.sameValue(a, 1); assert.sameValue(a, 1);
assert.sameValue(b, 2); assert.sameValue(b, 2);
assert.sameValue(x, 2); assert.sameValue(x, 2);

View File

@ -2,19 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern. position in the ArrayAssignmentPattern.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = []; //- setup
var result, argument, eval; var argument, eval;
//- elems
result = [arguments = 4, eval = 5] = value; [arguments = 4, eval = 5]
//- vals
assert.sameValue(result, value); []
//- body
assert.sameValue(arguments, 4); assert.sameValue(arguments, 4);
assert.sameValue(eval, 5); assert.sameValue(eval, 5);

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 It is a Syntax Error if LeftHandSideExpression is neither an
ObjectLiteral nor an ArrayLiteral and ObjectLiteral nor an ArrayLiteral and
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is IsValidSimpleAssignmentTarget(LeftHandSideExpression) is
false. false.
template: syntax
es6id: 12.14.5.1 es6id: 12.14.5.1
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
([arguments] = []); //- elems
[arguments]
//- values
[]

View File

@ -2,31 +2,34 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of an
AssignmentElement within a generator function body, it behaves as a AssignmentElement within a generator function body, it behaves as a
YieldExpression. YieldExpression.
template: default
es6id: 12.14.5.4 es6id: 12.14.5.4
features: [generators] features: [generators]
---*/ ---*/
//- setup
var value = []; var value = [];
var assignmentResult, iterationResult, iter, x; var iterationResult, iter, x;
iter = (function*() { iter = (function*() {
assignmentResult = [ x = yield ] = value; //- elems
[ x = yield ]
//- vals
[]
//- teardown
})(); })();
iterationResult = iter.next(); iterationResult = iter.next();
assert.sameValue(assignmentResult, undefined);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
iterationResult = iter.next(86); iterationResult = iter.next(86);
assert.sameValue(assignmentResult, value);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);
assert.sameValue(x, 86); assert.sameValue(x, 86);

View File

@ -2,13 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of an AssignmentElement
outside of a generator function body, it behaves as an IdentifierReference. outside of a generator function body, it behaves as an IdentifierReference.
template: syntax
es6id: 12.14.5.4 es6id: 12.14.5.4
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
var x; //- elems
[ x = yield ] = []; [ x = yield ]
//- vals
[]

View File

@ -2,18 +2,20 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of an AssignmentElement
outside of a generator function body, it behaves as an IdentifierReference. outside of a generator function body, it behaves as an IdentifierReference.
template: default
es6id: 12.14.5.4 es6id: 12.14.5.4
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = []; //- setup
var yield = 4; var yield = 4;
var result, x; var x;
//- elems
result = [ x = yield ] = value; [ x = yield ]
//- vals
assert.sameValue(result, value); []
//- body
assert.sameValue(x, 4); assert.sameValue(x, 4);

View File

@ -1,23 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
1. Let iterator be GetIterator(value). 1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
throw new Test262Error(); throw new Test262Error();
}; };
var x; var _;
//- error
assert.throws(Test262Error, function() { Test262Error
[ x ] = iterable; //- elems
}); [ _ ]
//- vals
iterable

View File

@ -1,20 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
[...] [...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var x; var _;
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
next: function() { next: function() {
@ -31,10 +33,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
assert.throws(Test262Error, function() { [ _ ]
[ x ] = iterable; //- vals
}); iterable
//- error
Test262Error
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
@ -20,11 +20,13 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
var x; //- setup
var _;
var iterable = {}; var iterable = {};
var nextCount = 0; var nextCount = 0;
var iterator = { var iterator = {
@ -41,7 +43,9 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
assert.throws(TypeError, function() { [ _ ]
[ x ] = iterable; //- vals
}); iterable
//- error
TypeError

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is not called when assignment evaluation has exhausted the
iterator iterator
info: | info: |
@ -11,13 +11,15 @@ info: |
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). 5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
6. Return result. 6. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var x; var _;
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
next: function() { next: function() {
@ -32,8 +34,10 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x ] = iterable; [ _ ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is called when assignment evaluation has not exhausted the
iterator iterator
info: | info: |
@ -18,15 +18,17 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
var args = null; var args = null;
var x; var _;
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
next: function() { next: function() {
@ -45,9 +47,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x ] = iterable; [ _ ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when reference evaluation produces a "return" IteratorClose is called when reference evaluation produces a "return"
completion completion
info: | info: |
@ -19,10 +19,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
var iterable = {}; var iterable = {};
@ -38,8 +40,13 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ {}[yield] ] = iterable; //- elems
[ {}[ yield ] ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();
iter.next(); iter.next();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
@ -20,10 +20,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
return: function() { return: function() {
@ -35,8 +37,13 @@ iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
function* g() { function* g() {
[ {}[yield] ] = iterable; //- elems
[ {}[yield] ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when reference evaluation produces a "return" IteratorClose is called when reference evaluation produces a "return"
completion completion
info: | info: |
@ -19,10 +19,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
var thisValue = null; var thisValue = null;
@ -42,8 +44,13 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ {}[yield] ] = iterable; //- elems
[ {}[yield] ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();
iter.next(); iter.next();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when reference evaluation produces a "throw" IteratorClose is called when reference evaluation produces a "throw"
completion completion
info: | info: |
@ -12,10 +12,12 @@ info: |
result). result).
6. Return result. 6. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
function ReturnError() {} function ReturnError() {}
@ -38,10 +40,12 @@ var thrower = function() {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ {}[thrower()] ] = iterable; //- elems
}); [ {}[thrower()] ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is not called when iteration produces an abrupt completion
info: | info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
@ -11,10 +11,12 @@ info: |
result). result).
6. Return result. 6. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -30,11 +32,13 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
var x; var _;
//- error
assert.throws(Test262Error, function() { Test262Error
[ x ] = iterable; //- elems
}); [ x ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when reference evaluation produces a "throw" IteratorClose is called when reference evaluation produces a "throw"
completion completion
info: | info: |
@ -18,10 +18,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -44,11 +46,13 @@ var thrower = function() {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ {}[thrower()] ] = iterable; //- elems
}); [ {}[thrower()] ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -2,15 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
or an ArrayLiteral and if the lexical token sequence matched by or an ArrayLiteral and if the lexical token sequence matched by
LeftHandSideExpression cannot be parsed with no tokens left over using LeftHandSideExpression cannot be parsed with no tokens left over using
AssignmentPattern as the goal symbol. AssignmentPattern as the goal symbol.
template: syntax
es6id: 12.14.5.1 es6id: 12.14.5.1
negative: SyntaxError negative: SyntaxError
---*/ ---*/
var x, y; //- elems
[[(x, y)]]
[...[(x, y)]] = [[]]; //- vals
[[]]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an array literal and the value is
`null`, a TypeError should be thrown. `null`, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var x; //- setup
var _;
assert.throws(TypeError, function() { //- error
[[ x ]] = [null]; TypeError
}); //- elems
[[ _ ]]
//- vals
[null]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an array literal and the value is a
"hole", a TypeError should be thrown. "hole", a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var x; //- setup
var _;
assert.throws(TypeError, function() { //- error
[[ x ]] = [ , ]; TypeError
}); //- elems
[[ _ ]]
//- vals
[ , ]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an array literal and the value is
`undefined`, a TypeError should be thrown. `undefined`, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var x; //- setup
var _;
assert.throws(TypeError, function() { //- error
[[ x ]] = [undefined]; TypeError
}); //- elems
[[ x ]]
//- vals
[undefined]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an array literal and no value is
defined, a TypeError should be thrown. defined, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var x; //- setup
var _;
assert.throws(TypeError, function() { //- error
[[ x ]] = []; TypeError
}); //- elems
[[ x ]]
//- vals
[]

View File

@ -2,32 +2,36 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment and within a generator function body, it nested destructuring assignment and within a generator function body, it
behaves as a YieldExpression. behaves as a YieldExpression.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
features: [generators] features: [generators]
---*/ ---*/
//- setup
var value = [[22]]; var value = [[22]];
var x = {}; var x = {};
var assignmentResult, iterationResult, iter; var iterationResult, iter;
iter = (function*() { iter = (function*() {
assignmentResult = [[x[yield]]] = value; //- elems
[[x[yield]]]
//- vals
value
//- teardown
}()); }());
iterationResult = iter.next(); iterationResult = iter.next();
assert.sameValue(assignmentResult, undefined);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined); assert.sameValue(x.prop, undefined);
iterationResult = iter.next('prop'); iterationResult = iter.next('prop');
assert.sameValue(assignmentResult, value);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 22); assert.sameValue(x.prop, 22);

View File

@ -2,13 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference. IdentifierReference.
template: syntax
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
[[x[yield]]] = value; //- elems
[[x[yield]]]
//- vals
[[]]

View File

@ -2,20 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference. IdentifierReference.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = [[22]]; //- setup
var yield = 'prop'; var yield = 'prop';
var x = {}; var x = {};
var result; //- elems
[[x[yield]]]
result = [[x[yield]]] = value; //- vals
[[22]]
assert.sameValue(result, value); //- body
assert.sameValue(x.prop, 22); assert.sameValue(x.prop, 22);

View File

@ -2,17 +2,19 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an array literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment. assignment.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [[1]]; //- setup
var x, result; var x;
//- elems
result = [[x]] = value; [[x]]
//- vals
assert.sameValue(result, value); [[1]]
//- body
assert.sameValue(x, 1); assert.sameValue(x, 1);

View File

@ -2,15 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
or an ArrayLiteral and if the lexical token sequence matched by or an ArrayLiteral and if the lexical token sequence matched by
LeftHandSideExpression cannot be parsed with no tokens left over using LeftHandSideExpression cannot be parsed with no tokens left over using
AssignmentPattern as the goal symbol. AssignmentPattern as the goal symbol.
template: syntax
es6id: 12.14.5.1 es6id: 12.14.5.1
negative: SyntaxError negative: SyntaxError
---*/ ---*/
var x, y; //- elems
[{ get x() {} }]
[[(x, y)]] = [[]]; //- vals
[{}]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an object literal and the value is
`null`, a TypeError should be thrown. `null`, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
//- setup
var x; var x;
//- error
assert.throws(TypeError, function() { TypeError
[{ x }] = [null]; //- elems
}); [{ x }]
//- vals
[null]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an object literal and the value is a
"hole", a TypeError should be thrown. "hole", a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
//- setup
var x; var x;
//- error
assert.throws(TypeError, function() { TypeError
[{ x }] = [ , ]; //- elems
}); [{ x }]
//- vals
[ , ]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an object literal and the value is
`undefined`, a TypeError should be thrown. `undefined`, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
//- setup
var x; var x;
//- error
assert.throws(TypeError, function() { TypeError
[{ x }] = [undefined]; //- elems
}); [{ x }]
//- vals
[undefined]

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When DestructuringAssignmentTarget is an object literal and no value is
defined, a TypeError should be thrown. defined, a TypeError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
//- setup
var x; var x;
//- error
assert.throws(TypeError, function() { TypeError
[{ x }] = []; //- elems
}); [{ x }]
//- vals
[]

View File

@ -2,31 +2,34 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of a nested
destructuring assignment and within a generator function body, it behaves destructuring assignment and within a generator function body, it behaves
as a YieldExpression. as a YieldExpression.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
features: [generators] features: [generators]
---*/ ---*/
var value = [{}]; //- setup
var assignmentResult, iterationResult, iter, x; var iterationResult, iter, x;
iter = (function*() { iter = (function*() {
assignmentResult = [{ x = yield }] = value; //- elems
[{ x = yield }]
//- vals
[{}]
//- teardown
}()); }());
iterationResult = iter.next(); iterationResult = iter.next();
assert.sameValue(assignmentResult, undefined);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
iterationResult = iter.next(4); iterationResult = iter.next(4);
assert.sameValue(assignmentResult, value);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);
assert.sameValue(x, 4); assert.sameValue(x, 4);

View File

@ -2,13 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of a nested
destructuring assignment outside of a generator function body, it behaves destructuring assignment outside of a generator function body, it behaves
as a IdentifierReference. as a IdentifierReference.
template: syntax
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
[{ x = yield }] = [{}]; //- elems
[{ x = yield }]
//- vals
[{}]

View File

@ -2,19 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the Initializer of a nested
destructuring assignment outside of a generator function body, it behaves destructuring assignment outside of a generator function body, it behaves
as an IdentifierReference. as an IdentifierReference.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = [{}]; //- setup
var yield = 2; var yield = 2;
var result, x; var x;
//- elems
result = [{ x = yield }] = value; [{ x = yield }]
//- vals
assert.sameValue(result, value); [{}]
//- body
assert.sameValue(x, 2); assert.sameValue(x, 2);

View File

@ -2,17 +2,19 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
When DestructuringAssignmentTarget is an object literal, it should be When DestructuringAssignmentTarget is an object literal, it should be
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment. assignment.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [{ x: 2 }]; //- setup
var result, x; var x;
//- elems
result = [{ x }] = value; [{ x }]
//- vals
assert.sameValue(result, value); [{ x: 2 }]
//- body
assert.sameValue(x, 2); assert.sameValue(x, 2);

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
The assignment target should obey `const` semantics. The assignment target should obey `const` semantics.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
features: [const] features: [const]
---*/ ---*/
//- setup
const c = null; const c = null;
//- error
assert.throws(TypeError, function() { TypeError
[ c ] = [1]; //- elems
}); [ c ]
//- vals
[1]

View File

@ -2,13 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
The assignment target should obey `let` semantics. The assignment target should obey `let` semantics.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
features: [let] features: [let]
---*/ ---*/
assert.throws(ReferenceError, function() { //- elems
[ ...x ] = []; [ x ]
//- vals
[]
//- error
ReferenceError
//- teardown
let x; let x;
});

View File

@ -2,14 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
If the DestructuringAssignmentTarget of an AssignmentElement is a If the DestructuringAssignmentTarget of an AssignmentElement is a
PropertyReference, it should not be evaluated. PropertyReference, it should not be evaluated.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [23]; //- setup
var x, setValue, result; var x, setValue;
x = { x = {
get y() { get y() {
$ERROR('The property should not be accessed.'); $ERROR('The property should not be accessed.');
@ -18,8 +19,9 @@ x = {
setValue = val; setValue = val;
} }
}; };
//- elems
result = [x.y] = value; [x.y]
//- vals
assert.sameValue(result, value); [23]
//- body
assert.sameValue(setValue, 23); assert.sameValue(setValue, 23);

View File

@ -2,19 +2,22 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 Any error raised as a result of setting the value should be forwarded to
the runtime. the runtime.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [23]; //- setup
var x = { var x = {
set y(val) { set y(val) {
throw new Test262Error(); throw new Test262Error();
} }
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[x.y] = value; //- elems
}); [x.y]
//- vals
[23]

View File

@ -2,17 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
The DestructuringAssignmentTarget of an AssignmentElement may be a The DestructuringAssignmentTarget of an AssignmentElement may be a
PropertyReference. PropertyReference.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [4]; //- setup
var x = {}; var x = {};
var result; //- elems
[x.y]
result = [x.y] = value; //- vals
[4]
assert.sameValue(result, value); //- body
assert.sameValue(x.y, 4); assert.sameValue(x.y, 4);

View File

@ -2,15 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 Outside of strict mode, if the the assignment target is an unresolvable
reference, a new `var` binding should be created in the environment record. reference, a new `var` binding should be created in the environment record.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [noStrict] flags: [noStrict]
---*/ ---*/
//- setup
{ {
[ unresolvable ] = []; //- elems
[ unresolvable ]
//- vals
[]
//- teardown
} }
assert.sameValue(unresolvable, undefined); assert.sameValue(unresolvable, undefined);

View File

@ -2,13 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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, In strict mode, if the the assignment target is an unresolvable reference,
a ReferenceError should be thrown. a ReferenceError should be thrown.
template: error
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
assert.throws(ReferenceError, function() { //- error
[ unresolvable ] = []; ReferenceError
}); //- elems
[ unresolvable ]
//- vals
[]

View File

@ -2,20 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern. position in the ArrayAssignmentPattern.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
---*/ ---*/
var value = [1, 2, 3]; //- setup
var x, y, z; var x, y, z;
var result; //- elems
[x, y, z]
result = [x, y, z] = value; //- vals
[1, 2, 3]
assert.sameValue(result, value); //- body
assert.sameValue(x, 1); assert.sameValue(x, 1);
assert.sameValue(y, 2); assert.sameValue(y, 2);
assert.sameValue(z, 3); assert.sameValue(z, 3);

View File

@ -2,19 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern. position in the ArrayAssignmentPattern.
template: default
es6id: 12.14.5.3 es6id: 12.14.5.3
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = [2, 3]; //- setup
var result, argument, eval; var argument, eval;
//- elems
result = [arguments, eval] = value; [arguments, eval]
//- vals
assert.sameValue(result, value); [2, 3]
//- body
assert.sameValue(arguments, 2); assert.sameValue(arguments, 2);
assert.sameValue(eval, 3); assert.sameValue(eval, 3);

View File

@ -2,14 +2,18 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 It is a Syntax Error if LeftHandSideExpression is neither an
ObjectLiteral nor an ArrayLiteral and ObjectLiteral nor an ArrayLiteral and
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is IsValidSimpleAssignmentTarget(LeftHandSideExpression) is
false. false.
template: syntax
es6id: 12.14.5.1 es6id: 12.14.5.1
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
([arguments] = []); //- elems
[arguments]
//- vals
[]

View File

@ -2,32 +2,36 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement within a generator function body, it behaves as a AssignmentElement within a generator function body, it behaves as a
YieldExpression. YieldExpression.
template: default
es6id: 12.14.5.4 es6id: 12.14.5.4
features: [generators] features: [generators]
---*/ ---*/
//- setup
var value = [33]; var value = [33];
var x = {}; var x = {};
var assignmentResult, iterationResult, iter; var iterationResult, iter;
iter = (function*() { iter = (function*() {
assignmentResult = [ x[yield] ] = value; //- elems
[ x[yield] ]
//- vals
[33]
//- teardown
}()); }());
iterationResult = iter.next(); iterationResult = iter.next();
assert.sameValue(assignmentResult, undefined);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined); assert.sameValue(x.prop, undefined);
iterationResult = iter.next('prop'); iterationResult = iter.next('prop');
assert.sameValue(assignmentResult, value);
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 33); assert.sameValue(x.prop, 33);

View File

@ -2,13 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement and outside of a generator function body, it behaves as AssignmentElement and outside of a generator function body, it behaves as
an IdentifierReference. an IdentifierReference.
template: syntax
es6id: 12.14.5.4 es6id: 12.14.5.4
flags: [onlyStrict] flags: [onlyStrict]
negative: SyntaxError negative: SyntaxError
---*/ ---*/
[ x[yield] ] = []; //- elems
[ x[yield] ]
//- vals
[]

View File

@ -2,20 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement outside of a generator function body, it behaves as an AssignmentElement outside of a generator function body, it behaves as an
IdentifierReference. IdentifierReference.
template: default
es6id: 12.14.5.4 es6id: 12.14.5.4
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var value = [33]; //- setup
var yield = 'prop'; var yield = 'prop';
var x = {}; var x = {};
var result; //- elems
[ x[yield] ]
result = [ x[yield] ] = value; //- vals
[33]
assert.sameValue(result, value); //- body
assert.sameValue(x.prop, 33); assert.sameValue(x.prop, 33);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -16,10 +16,12 @@ info: |
IteratorClose(iterator, status). IteratorClose(iterator, status).
ii. Return Completion(status). ii. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -44,9 +46,12 @@ iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
assert.throws(Test262Error, function() { //- error
[ x , , ] = iterable; Test262Error
}); //- elems
[ x , , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 2); assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -16,10 +16,12 @@ info: |
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status). status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -40,10 +42,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , , ] = iterable; //- elems
}); [ x , , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 2); assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
@ -26,10 +26,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var x; var x;
var nextCount = 0; var nextCount = 0;
@ -47,7 +49,9 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(TypeError, function() { TypeError
[ x , , ] = iterable; //- elems
}); [ x , , ]
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -17,10 +17,12 @@ info: |
status). status).
9. Return Completion(status). 9. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -38,8 +40,10 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x , , ] = iterable; [ x , , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 2); assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -22,10 +22,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -50,9 +52,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x , , ] = iterable; [ x , , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 2); assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -9,16 +9,20 @@ info: |
1. Let iterator be GetIterator(value). 1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
throw new Test262Error(); throw new Test262Error();
}; };
var x; var x;
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ] = iterable; //- elems
}); [ x , ]
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -16,10 +16,12 @@ info: |
status). status).
b. Return Completion(status). b. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -40,10 +42,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ] = iterable; //- elems
}); [ x , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
@ -26,10 +26,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var x; var x;
var nextCount = 0; var nextCount = 0;
@ -47,7 +49,9 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(TypeError, function() { TypeError
[ x , ] = iterable; //- elems
}); [ x , ]
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is not invoked when evaluation of AssignmentElementList IteratorClose is not invoked when evaluation of AssignmentElementList
exhausts the iterator exhausts the iterator
info: | info: |
@ -18,10 +18,12 @@ info: |
status). status).
b. Return Completion(status). b. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -41,8 +43,10 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x , ] = iterable; [ x , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is invoked when evaluation of AssignmentElementList completes IteratorClose is invoked when evaluation of AssignmentElementList completes
without exhausting the iterator without exhausting the iterator
info: | info: |
@ -24,10 +24,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -51,9 +53,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x , ] = iterable; [ x , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns IteratorClose is invoked when evaluation of AssignmentElementList returns
a "return" completion and the iterator has not been marked as "done" a "return" completion and the iterator has not been marked as "done"
info: | info: |
@ -24,10 +24,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
var iterable = {}; var iterable = {};
@ -44,8 +46,13 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ {}[yield] , ] = iterable; //- elems
[ {}[yield] , ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
@ -26,10 +26,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
return: function() { return: function() {
@ -42,7 +44,11 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ {}[yield] , ] = iterable; //- elems
[ {}[yield] , ]
//- vals
iterable
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns IteratorClose is invoked when evaluation of AssignmentElementList returns
a "return" completion and the iterator has not been marked as "done" a "return" completion and the iterator has not been marked as "done"
info: | info: |
@ -25,10 +25,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
var thisValue = null; var thisValue = null;
@ -49,8 +51,13 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ {}[yield] , ] = iterable; //- elems
[ {}[yield] , ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
}; };
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns IteratorClose is invoked when evaluation of AssignmentElementList returns
a "throw" completion and the iterator has not been marked as "done" a "throw" completion and the iterator has not been marked as "done"
info: | info: |
@ -23,10 +23,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -50,9 +52,13 @@ iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
assert.throws(Test262Error, function() { //- error
[ {}[thrower()] , ] = iterable; Test262Error
}); //- elems
[ {}[thrower()] , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is not invoked when evaluation of AssignmentElementList IteratorClose is not invoked when evaluation of AssignmentElementList
returns an abrupt completion and the iterator has been marked as "done" returns an abrupt completion and the iterator has been marked as "done"
info: | info: |
@ -18,10 +18,12 @@ info: |
status). status).
b. Return Completion(status). b. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -41,10 +43,12 @@ iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
var x; var x;
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ] = iterable; //- elems
}); [ x , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns IteratorClose is invoked when evaluation of AssignmentElementList returns
a "throw" completion and the iterator has not been marked as "done" a "throw" completion and the iterator has not been marked as "done"
info: | info: |
@ -24,10 +24,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -50,11 +52,13 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ {}[thrower()] , ] = iterable; //- elems
}); [ {}[thrower()] , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is not called when rest element evaluation has exhausted the
iterator iterator
info: | info: |
@ -17,10 +17,12 @@ info: |
status). status).
9. Return Completion(status). 9. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -37,9 +39,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ x , ...y ] = iterable; [ x , ...y ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 2, 'nextCount'); assert.sameValue(nextCount, 2, 'nextCount');
assert.sameValue(returnCount, 0, 'returnCount'); assert.sameValue(returnCount, 0, 'returnCount');
assert.sameValue(x, 1, 'x'); assert.sameValue(x, 1, 'x');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when AssignmentRestEvaluation produces a "return" IteratorClose is called when AssignmentRestEvaluation produces a "return"
completion due to reference evaluation completion due to reference evaluation
info: | info: |
@ -24,10 +24,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
@ -51,8 +53,13 @@ iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
function* g() { function* g() {
[ x , ...{}[yield] ] = iterable; //- elems
[ x , ...{}[yield] ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
@ -23,10 +23,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var iterable = {}; var iterable = {};
var x; var x;
@ -47,7 +49,11 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ x , ...{}[yield] ] = iterable; //- elems
[ x , ...{}[yield] ]
//- vals
iterable
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when AssignmentRestEvaluation produces a "return" IteratorClose is called when AssignmentRestEvaluation produces a "return"
completion due to reference evaluation completion due to reference evaluation
info: | info: |
@ -24,10 +24,12 @@ info: |
7. If completion.[[type]] is throw, return Completion(completion). 7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult). 8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators] features: [Symbol.iterator, generators]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var unreachable = 0; var unreachable = 0;
@ -55,8 +57,13 @@ iterable[Symbol.iterator] = function() {
}; };
function* g() { function* g() {
[ x , ...{}[yield] ] = iterable; //- elems
[ x , ...{}[yield] ]
//- vals
iterable
//- body
unreachable += 1; unreachable += 1;
//- teardown
} }
iter = g(); iter = g();

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when AssignmentRestEvaluation produces a "throw" IteratorClose is called when AssignmentRestEvaluation produces a "throw"
completion due to reference evaluation completion due to reference evaluation
info: | info: |
@ -22,10 +22,12 @@ info: |
[...] [...]
7. If completion.[[type]] is throw, return Completion(completion) 7. If completion.[[type]] is throw, return Completion(completion)
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var x; var x;
@ -51,10 +53,12 @@ var thrower = function() {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ...{}[thrower()] ] = iterable; //- elems
}); [ x , ...{}[thrower()] ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
@ -15,10 +15,12 @@ info: |
status). status).
9. Return Completion(status). 9. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -42,10 +44,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ...x ] = iterable; //- elems
}); [ x , ...x ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 2); assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
IteratorClose is called when AssignmentRestEvaluation produces a "throw" IteratorClose is called when AssignmentRestEvaluation produces a "throw"
completion due to reference evaluation completion due to reference evaluation
info: | info: |
@ -23,10 +23,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -52,11 +54,13 @@ var thrower = function() {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ x , ...{}[thrower()] ] = iterable; //- elems
}); [ x , ...{}[thrower()] ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is not called when iteration produces an abrupt completion
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
@ -12,10 +12,12 @@ info: |
result). result).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -31,10 +33,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ , ] = iterable; //- elems
}); [ , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,22 +1,26 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
1. Let iterator be GetIterator(value). 1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
throw new Test262Error(); throw new Test262Error();
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ , ] = iterable; //- elems
}); [ , ]
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > desc: >
Abrupt completion returned from IteratorClose Abrupt completion returned from IteratorClose
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
@ -12,10 +12,12 @@ info: |
result). result).
6. Return result. 6. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -34,10 +36,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[ , ] = iterable; //- elems
}); [ , ]
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
@ -21,10 +21,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var nextCount = 0; var nextCount = 0;
var iterator = { var iterator = {
@ -41,7 +43,9 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(TypeError, function() { TypeError
[ , ] = iterable; //- elems
}); [ , ]
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is not called when iteration has exhausted the iterator
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
@ -12,10 +12,12 @@ info: |
result). result).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -32,8 +34,10 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ , ] = iterable; [ , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose is called when assignment evaluation has not exhausted the
iterator iterator
info: | info: |
@ -19,10 +19,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -45,9 +47,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[ , ] = iterable; [ , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -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
[]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ ] ArrayAssignmentPattern : [ ]
@ -9,10 +9,12 @@ info: |
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
3. Return IteratorClose(iterator, NormalCompletion(empty)). 3. Return IteratorClose(iterator, NormalCompletion(empty)).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var iterable = {}; var iterable = {};
@ -29,10 +31,12 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[] = iterable; //- elems
}); []
//- vals
iterable
//- teardown
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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 IteratorClose throws a TypeError when `return` returns a non-Object value
info: | info: |
ArrayAssignmentPattern : [ ] ArrayAssignmentPattern : [ ]
@ -19,10 +19,12 @@ info: |
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception. exception.
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
var iterator = { var iterator = {
next: function() { next: function() {
@ -35,7 +37,9 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- error
assert.throws(TypeError, function() { TypeError
[] = iterable; //- elems
}); []
//- vals
iterable

View File

@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ ] ArrayAssignmentPattern : [ ]
@ -15,10 +15,12 @@ info: |
6. Let innerResult be Call(return, iterator, « »). 6. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var nextCount = 0; var nextCount = 0;
var returnCount = 0; var returnCount = 0;
var thisValue = null; var thisValue = null;
@ -39,9 +41,11 @@ var iterator = {
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return iterator; return iterator;
}; };
//- elems
[] = iterable; []
//- vals
iterable
//- body
assert.sameValue(nextCount, 0); assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1); assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value'); assert.sameValue(thisValue, iterator, 'correct `this` value');

View File

@ -1,22 +1,26 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // 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: | info: |
ArrayAssignmentPattern : [ ] ArrayAssignmentPattern : [ ]
1. Let iterator be GetIterator(value). 1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator] features: [Symbol.iterator]
template: error
es6id: 12.14.5.2 es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup
var iterable = {}; var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
throw new Test262Error(); throw new Test262Error();
}; };
//- error
assert.throws(Test262Error, function() { Test262Error
[] = iterable; //- elems
}); []
//- vals
iterable

View File

@ -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
[]

View File

@ -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

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More