mirror of https://github.com/tc39/test262.git
Merge pull request #651 from bocoup/generation-dstr-assign
Re-format destructuring assignment tests
This commit is contained in:
commit
2cf968cfad
|
@ -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);
|
|
@ -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);
|
|
@ -2,7 +2,8 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Assignment of function `name` attribute (ArrowFunction)
|
||||
desc: Assignment of function `name` attribute (ArrowFunction)
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
info: >
|
||||
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
|
||||
|
@ -18,10 +19,13 @@ info: >
|
|||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var arrow;
|
||||
|
||||
[ arrow = () => {} ] = [];
|
||||
|
||||
//- elems
|
||||
[ arrow = () => {} ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.sameValue(arrow.name, 'arrow');
|
||||
verifyNotEnumerable(arrow, 'name');
|
||||
verifyNotWritable(arrow, 'name');
|
|
@ -2,7 +2,8 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Assignment of function `name` attribute (ClassExpression)
|
||||
desc: Assignment of function `name` attribute (ClassExpression)
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
info: >
|
||||
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
|
||||
|
@ -19,11 +20,13 @@ includes: [propertyHelper.js]
|
|||
features: [class]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var xCls, cls;
|
||||
|
||||
[ xCls = class x {} ] = [];;
|
||||
[ cls = class {} ] = [];
|
||||
|
||||
//- elems
|
||||
[ xCls = class x {},cls = class {} ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert(xCls.name !== 'xCls');
|
||||
|
||||
assert.sameValue(cls.name, 'cls');
|
|
@ -2,8 +2,9 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Assignment of function `name` attribute (CoverParenthesizedExpression)
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
info: >
|
||||
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
|
||||
|
@ -19,11 +20,13 @@ info: >
|
|||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var xCover, cover;
|
||||
|
||||
[ xCover = (0, function() {}) ] = [];
|
||||
[ cover = (function() {}) ] = [];
|
||||
|
||||
//- elems
|
||||
[ xCover = (0, function() {}), cover = (function() {}) ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert(xCover.name !== 'xCover');
|
||||
|
||||
assert.sameValue(cover.name, 'cover');
|
|
@ -2,7 +2,8 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Assignment of function `name` attribute (FunctionExpression)
|
||||
desc: Assignment of function `name` attribute (FunctionExpression)
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
info: >
|
||||
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
|
||||
|
@ -19,11 +20,13 @@ includes: [propertyHelper.js]
|
|||
features: [class]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var xFn, fn;
|
||||
|
||||
[ xFn = function x() {} ] = [];;
|
||||
[ fn = function() {} ] = [];
|
||||
|
||||
//- elems
|
||||
[ xFn = function x() {}, fn = function() {} ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert(xFn.name !== 'xFn');
|
||||
|
||||
assert.sameValue(fn.name, 'fn');
|
|
@ -2,7 +2,8 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Assignment of function `name` attribute (GeneratorExpression)
|
||||
desc: Assignment of function `name` attribute (GeneratorExpression)
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
info: >
|
||||
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
|
||||
|
@ -19,12 +20,14 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var xGen, gen;
|
||||
|
||||
[ xGen = function* x() {} ] = [];
|
||||
[ gen = function*() {} ] = [];;
|
||||
|
||||
assert(xGen.name !== 'xGen');
|
||||
//- elems
|
||||
[ xGen = function* x() {}, gen = function*() {} ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.notSameValue(xGen.name, 'xGen');
|
||||
|
||||
assert.sameValue(gen.name, 'gen');
|
||||
verifyNotEnumerable(gen, 'name');
|
|
@ -2,15 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
The Initializer in an AssignmentElement may be an `in` expression.
|
||||
template: default
|
||||
es6id: 12.14.5
|
||||
---*/
|
||||
|
||||
var value = [];
|
||||
var result, x;
|
||||
|
||||
result = [ x = 'x' in {} ] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- setup
|
||||
var x;
|
||||
//- elems
|
||||
[ x = 'x' in {} ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.sameValue(x, false);
|
|
@ -2,15 +2,20 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Value retrieval of Initializer obeys `let` semantics.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
features: [let]
|
||||
---*/
|
||||
|
||||
//- error
|
||||
ReferenceError
|
||||
//- setup
|
||||
var x;
|
||||
|
||||
assert.throws(ReferenceError, function() {
|
||||
[ x = y ] = [];
|
||||
let y;
|
||||
});
|
||||
//- elems
|
||||
[ x = y ]
|
||||
//- vals
|
||||
[]
|
||||
//- teardown
|
||||
let y;
|
|
@ -2,18 +2,20 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Initializer values should be assigned in left-to-right order.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [];
|
||||
//- setup
|
||||
var x = 0;
|
||||
var a, b, result;
|
||||
|
||||
result = [ a = x += 1, b = x *= 2 ] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
var a, b;
|
||||
//- elems
|
||||
[ a = x += 1, b = x *= 2 ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.sameValue(a, 1);
|
||||
assert.sameValue(b, 2);
|
||||
assert.sameValue(x, 2);
|
|
@ -2,19 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Identifiers that appear as the DestructuringAssignmentTarget in an
|
||||
AssignmentElement should take on the iterated value corresponding to their
|
||||
position in the ArrayAssignmentPattern.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [];
|
||||
var result, argument, eval;
|
||||
|
||||
result = [arguments = 4, eval = 5] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- setup
|
||||
var argument, eval;
|
||||
//- elems
|
||||
[arguments = 4, eval = 5]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.sameValue(arguments, 4);
|
||||
assert.sameValue(eval, 5);
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
It is a Syntax Error if LeftHandSideExpression is neither an
|
||||
ObjectLiteral nor an ArrayLiteral and
|
||||
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is
|
||||
false.
|
||||
template: syntax
|
||||
es6id: 12.14.5.1
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
([arguments] = []);
|
||||
//- elems
|
||||
[arguments]
|
||||
//- values
|
||||
[]
|
|
@ -2,31 +2,34 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of an
|
||||
AssignmentElement within a generator function body, it behaves as a
|
||||
YieldExpression.
|
||||
template: default
|
||||
es6id: 12.14.5.4
|
||||
features: [generators]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var value = [];
|
||||
var assignmentResult, iterationResult, iter, x;
|
||||
|
||||
var iterationResult, iter, x;
|
||||
iter = (function*() {
|
||||
assignmentResult = [ x = yield ] = value;
|
||||
//- elems
|
||||
[ x = yield ]
|
||||
//- vals
|
||||
[]
|
||||
//- teardown
|
||||
})();
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert.sameValue(assignmentResult, undefined);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, false);
|
||||
assert.sameValue(x, undefined);
|
||||
|
||||
iterationResult = iter.next(86);
|
||||
|
||||
assert.sameValue(assignmentResult, value);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, true);
|
||||
assert.sameValue(x, 86);
|
|
@ -2,13 +2,16 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of an AssignmentElement
|
||||
outside of a generator function body, it behaves as an IdentifierReference.
|
||||
template: syntax
|
||||
es6id: 12.14.5.4
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
var x;
|
||||
[ x = yield ] = [];
|
||||
//- elems
|
||||
[ x = yield ]
|
||||
//- vals
|
||||
[]
|
|
@ -2,18 +2,20 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of an AssignmentElement
|
||||
outside of a generator function body, it behaves as an IdentifierReference.
|
||||
template: default
|
||||
es6id: 12.14.5.4
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [];
|
||||
//- setup
|
||||
var yield = 4;
|
||||
var result, x;
|
||||
|
||||
result = [ x = yield ] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
var x;
|
||||
//- elems
|
||||
[ x = yield ]
|
||||
//- vals
|
||||
[]
|
||||
//- body
|
||||
assert.sameValue(x, 4);
|
|
@ -1,23 +1,27 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from GetIterator
|
||||
desc: Abrupt completion returned from GetIterator
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ AssignmentElementList ]
|
||||
|
||||
1. Let iterator be GetIterator(value).
|
||||
2. ReturnIfAbrupt(iterator).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
var x;
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x ] = iterable;
|
||||
});
|
||||
var _;
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ _ ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,20 +1,22 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from IteratorClose
|
||||
desc: Abrupt completion returned from IteratorClose
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ AssignmentElementList ]
|
||||
|
||||
[...]
|
||||
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var x;
|
||||
var _;
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
next: function() {
|
||||
|
@ -31,10 +33,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x ] = iterable;
|
||||
});
|
||||
|
||||
//- elems
|
||||
[ _ ]
|
||||
//- vals
|
||||
iterable
|
||||
//- error
|
||||
Test262Error
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ AssignmentElementList ]
|
||||
|
@ -20,11 +20,13 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
var x;
|
||||
//- setup
|
||||
var _;
|
||||
var iterable = {};
|
||||
var nextCount = 0;
|
||||
var iterator = {
|
||||
|
@ -41,7 +43,9 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[ x ] = iterable;
|
||||
});
|
||||
//- elems
|
||||
[ _ ]
|
||||
//- vals
|
||||
iterable
|
||||
//- error
|
||||
TypeError
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not called when assignment evaluation has exhausted the
|
||||
iterator
|
||||
info: |
|
||||
|
@ -11,13 +11,15 @@ info: |
|
|||
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
|
||||
6. Return result.
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var x;
|
||||
var _;
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
next: function() {
|
||||
|
@ -32,8 +34,10 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ _ ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when assignment evaluation has not exhausted the
|
||||
iterator
|
||||
info: |
|
||||
|
@ -18,15 +18,17 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
var args = null;
|
||||
var x;
|
||||
var _;
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
next: function() {
|
||||
|
@ -45,9 +47,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ _ ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when reference evaluation produces a "return"
|
||||
completion
|
||||
info: |
|
||||
|
@ -19,10 +19,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
var iterable = {};
|
||||
|
@ -38,8 +40,13 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ {}[yield] ] = iterable;
|
||||
unreachable += 1;
|
||||
//- elems
|
||||
[ {}[ yield ] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
iter = g();
|
||||
iter.next();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ AssignmentElementList ]
|
||||
|
@ -20,10 +20,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
return: function() {
|
||||
|
@ -35,8 +37,13 @@ iterable[Symbol.iterator] = function() {
|
|||
return iterator;
|
||||
};
|
||||
function* g() {
|
||||
[ {}[yield] ] = iterable;
|
||||
//- elems
|
||||
[ {}[yield] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when reference evaluation produces a "return"
|
||||
completion
|
||||
info: |
|
||||
|
@ -19,10 +19,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
var thisValue = null;
|
||||
|
@ -42,8 +44,13 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ {}[yield] ] = iterable;
|
||||
unreachable += 1;
|
||||
//- elems
|
||||
[ {}[yield] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
iter = g();
|
||||
iter.next();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when reference evaluation produces a "throw"
|
||||
completion
|
||||
info: |
|
||||
|
@ -12,10 +12,12 @@ info: |
|
|||
result).
|
||||
6. Return result.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
function ReturnError() {}
|
||||
|
@ -38,10 +40,12 @@ var thrower = function() {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ {}[thrower()] ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ {}[thrower()] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not called when iteration produces an abrupt completion
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ AssignmentElementList ]
|
||||
|
@ -11,10 +11,12 @@ info: |
|
|||
result).
|
||||
6. Return result.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -30,11 +32,13 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
var x;
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x ] = iterable;
|
||||
});
|
||||
|
||||
var _;
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when reference evaluation produces a "throw"
|
||||
completion
|
||||
info: |
|
||||
|
@ -18,10 +18,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -44,11 +46,13 @@ var thrower = function() {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ {}[thrower()] ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ {}[thrower()] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -2,15 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
|
||||
or an ArrayLiteral and if the lexical token sequence matched by
|
||||
LeftHandSideExpression cannot be parsed with no tokens left over using
|
||||
AssignmentPattern as the goal symbol.
|
||||
template: syntax
|
||||
es6id: 12.14.5.1
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
var x, y;
|
||||
|
||||
[...[(x, y)]] = [[]];
|
||||
//- elems
|
||||
[[(x, y)]]
|
||||
//- vals
|
||||
[[]]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an array literal and the value is
|
||||
`null`, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[[ x ]] = [null];
|
||||
});
|
||||
//- setup
|
||||
var _;
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[[ _ ]]
|
||||
//- vals
|
||||
[null]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an array literal and the value is a
|
||||
"hole", a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[[ x ]] = [ , ];
|
||||
});
|
||||
//- setup
|
||||
var _;
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[[ _ ]]
|
||||
//- vals
|
||||
[ , ]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an array literal and the value is
|
||||
`undefined`, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[[ x ]] = [undefined];
|
||||
});
|
||||
//- setup
|
||||
var _;
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[[ x ]]
|
||||
//- vals
|
||||
[undefined]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an array literal and no value is
|
||||
defined, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[[ x ]] = [];
|
||||
});
|
||||
//- setup
|
||||
var _;
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[[ x ]]
|
||||
//- vals
|
||||
[]
|
|
@ -2,32 +2,36 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of a
|
||||
nested destructuring assignment and within a generator function body, it
|
||||
behaves as a YieldExpression.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
features: [generators]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var value = [[22]];
|
||||
var x = {};
|
||||
var assignmentResult, iterationResult, iter;
|
||||
var iterationResult, iter;
|
||||
|
||||
iter = (function*() {
|
||||
assignmentResult = [[x[yield]]] = value;
|
||||
//- elems
|
||||
[[x[yield]]]
|
||||
//- vals
|
||||
value
|
||||
//- teardown
|
||||
}());
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert.sameValue(assignmentResult, undefined);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, false);
|
||||
assert.sameValue(x.prop, undefined);
|
||||
|
||||
iterationResult = iter.next('prop');
|
||||
|
||||
assert.sameValue(assignmentResult, value);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, true);
|
||||
assert.sameValue(x.prop, 22);
|
|
@ -2,13 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of a
|
||||
nested destructuring assignment outside of strict mode, it behaves as an
|
||||
IdentifierReference.
|
||||
template: syntax
|
||||
es6id: 12.14.5.3
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
[[x[yield]]] = value;
|
||||
//- elems
|
||||
[[x[yield]]]
|
||||
//- vals
|
||||
[[]]
|
|
@ -2,20 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of a
|
||||
nested destructuring assignment outside of strict mode, it behaves as an
|
||||
IdentifierReference.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [[22]];
|
||||
//- setup
|
||||
var yield = 'prop';
|
||||
var x = {};
|
||||
var result;
|
||||
|
||||
result = [[x[yield]]] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- elems
|
||||
[[x[yield]]]
|
||||
//- vals
|
||||
[[22]]
|
||||
//- body
|
||||
assert.sameValue(x.prop, 22);
|
|
@ -2,17 +2,19 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an array literal, it should be parsed
|
||||
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
|
||||
assignment.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [[1]];
|
||||
var x, result;
|
||||
|
||||
result = [[x]] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- setup
|
||||
var x;
|
||||
//- elems
|
||||
[[x]]
|
||||
//- vals
|
||||
[[1]]
|
||||
//- body
|
||||
assert.sameValue(x, 1);
|
|
@ -2,15 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
|
||||
or an ArrayLiteral and if the lexical token sequence matched by
|
||||
LeftHandSideExpression cannot be parsed with no tokens left over using
|
||||
AssignmentPattern as the goal symbol.
|
||||
template: syntax
|
||||
es6id: 12.14.5.1
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
var x, y;
|
||||
|
||||
[[(x, y)]] = [[]];
|
||||
//- elems
|
||||
[{ get x() {} }]
|
||||
//- vals
|
||||
[{}]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an object literal and the value is
|
||||
`null`, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[{ x }] = [null];
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[{ x }]
|
||||
//- vals
|
||||
[null]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an object literal and the value is a
|
||||
"hole", a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[{ x }] = [ , ];
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[{ x }]
|
||||
//- vals
|
||||
[ , ]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an object literal and the value is
|
||||
`undefined`, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[{ x }] = [undefined];
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[{ x }]
|
||||
//- vals
|
||||
[undefined]
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an object literal and no value is
|
||||
defined, a TypeError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var x;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[{ x }] = [];
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[{ x }]
|
||||
//- vals
|
||||
[]
|
|
@ -2,31 +2,34 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of a nested
|
||||
destructuring assignment and within a generator function body, it behaves
|
||||
as a YieldExpression.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
features: [generators]
|
||||
---*/
|
||||
|
||||
var value = [{}];
|
||||
var assignmentResult, iterationResult, iter, x;
|
||||
//- setup
|
||||
var iterationResult, iter, x;
|
||||
|
||||
iter = (function*() {
|
||||
assignmentResult = [{ x = yield }] = value;
|
||||
//- elems
|
||||
[{ x = yield }]
|
||||
//- vals
|
||||
[{}]
|
||||
//- teardown
|
||||
}());
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert.sameValue(assignmentResult, undefined);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, false);
|
||||
assert.sameValue(x, undefined);
|
||||
|
||||
iterationResult = iter.next(4);
|
||||
|
||||
assert.sameValue(assignmentResult, value);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, true);
|
||||
assert.sameValue(x, 4);
|
|
@ -2,13 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of a nested
|
||||
destructuring assignment outside of a generator function body, it behaves
|
||||
as a IdentifierReference.
|
||||
template: syntax
|
||||
es6id: 12.14.5.3
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
[{ x = yield }] = [{}];
|
||||
//- elems
|
||||
[{ x = yield }]
|
||||
//- vals
|
||||
[{}]
|
|
@ -2,19 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the Initializer of a nested
|
||||
destructuring assignment outside of a generator function body, it behaves
|
||||
as an IdentifierReference.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [{}];
|
||||
//- setup
|
||||
var yield = 2;
|
||||
var result, x;
|
||||
|
||||
result = [{ x = yield }] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
var x;
|
||||
//- elems
|
||||
[{ x = yield }]
|
||||
//- vals
|
||||
[{}]
|
||||
//- body
|
||||
assert.sameValue(x, 2);
|
|
@ -2,17 +2,19 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When DestructuringAssignmentTarget is an object literal, it should be
|
||||
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
|
||||
assignment.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [{ x: 2 }];
|
||||
var result, x;
|
||||
|
||||
result = [{ x }] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- setup
|
||||
var x;
|
||||
//- elems
|
||||
[{ x }]
|
||||
//- vals
|
||||
[{ x: 2 }]
|
||||
//- body
|
||||
assert.sameValue(x, 2);
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
The assignment target should obey `const` semantics.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
features: [const]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
const c = null;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[ c ] = [1];
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[ c ]
|
||||
//- vals
|
||||
[1]
|
|
@ -2,13 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
The assignment target should obey `let` semantics.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
features: [let]
|
||||
---*/
|
||||
|
||||
assert.throws(ReferenceError, function() {
|
||||
[ ...x ] = [];
|
||||
let x;
|
||||
});
|
||||
//- elems
|
||||
[ x ]
|
||||
//- vals
|
||||
[]
|
||||
//- error
|
||||
ReferenceError
|
||||
//- teardown
|
||||
let x;
|
|
@ -2,14 +2,15 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
If the DestructuringAssignmentTarget of an AssignmentElement is a
|
||||
PropertyReference, it should not be evaluated.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [23];
|
||||
var x, setValue, result;
|
||||
//- setup
|
||||
var x, setValue;
|
||||
x = {
|
||||
get y() {
|
||||
$ERROR('The property should not be accessed.');
|
||||
|
@ -18,8 +19,9 @@ x = {
|
|||
setValue = val;
|
||||
}
|
||||
};
|
||||
|
||||
result = [x.y] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- elems
|
||||
[x.y]
|
||||
//- vals
|
||||
[23]
|
||||
//- body
|
||||
assert.sameValue(setValue, 23);
|
|
@ -2,19 +2,22 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Any error raised as a result of setting the value should be forwarded to
|
||||
the runtime.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [23];
|
||||
//- setup
|
||||
var x = {
|
||||
set y(val) {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[x.y] = value;
|
||||
});
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[x.y]
|
||||
//- vals
|
||||
[23]
|
|
@ -2,17 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
The DestructuringAssignmentTarget of an AssignmentElement may be a
|
||||
PropertyReference.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [4];
|
||||
//- setup
|
||||
var x = {};
|
||||
var result;
|
||||
|
||||
result = [x.y] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- elems
|
||||
[x.y]
|
||||
//- vals
|
||||
[4]
|
||||
//- body
|
||||
assert.sameValue(x.y, 4);
|
|
@ -2,15 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Outside of strict mode, if the the assignment target is an unresolvable
|
||||
reference, a new `var` binding should be created in the environment record.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
{
|
||||
[ unresolvable ] = [];
|
||||
//- elems
|
||||
[ unresolvable ]
|
||||
//- vals
|
||||
[]
|
||||
//- teardown
|
||||
}
|
||||
|
||||
assert.sameValue(unresolvable, undefined);
|
|
@ -2,13 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
In strict mode, if the the assignment target is an unresolvable reference,
|
||||
a ReferenceError should be thrown.
|
||||
template: error
|
||||
es6id: 12.14.5.3
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
assert.throws(ReferenceError, function() {
|
||||
[ unresolvable ] = [];
|
||||
});
|
||||
//- error
|
||||
ReferenceError
|
||||
//- elems
|
||||
[ unresolvable ]
|
||||
//- vals
|
||||
[]
|
|
@ -2,20 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Identifiers that appear as the DestructuringAssignmentTarget in an
|
||||
AssignmentElement should take on the iterated value corresponding to their
|
||||
position in the ArrayAssignmentPattern.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
---*/
|
||||
|
||||
var value = [1, 2, 3];
|
||||
//- setup
|
||||
var x, y, z;
|
||||
var result;
|
||||
|
||||
result = [x, y, z] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- elems
|
||||
[x, y, z]
|
||||
//- vals
|
||||
[1, 2, 3]
|
||||
//- body
|
||||
assert.sameValue(x, 1);
|
||||
assert.sameValue(y, 2);
|
||||
assert.sameValue(z, 3);
|
|
@ -2,19 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Identifiers that appear as the DestructuringAssignmentTarget in an
|
||||
AssignmentElement should take on the iterated value corresponding to their
|
||||
position in the ArrayAssignmentPattern.
|
||||
template: default
|
||||
es6id: 12.14.5.3
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [2, 3];
|
||||
var result, argument, eval;
|
||||
|
||||
result = [arguments, eval] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- setup
|
||||
var argument, eval;
|
||||
//- elems
|
||||
[arguments, eval]
|
||||
//- vals
|
||||
[2, 3]
|
||||
//- body
|
||||
assert.sameValue(arguments, 2);
|
||||
assert.sameValue(eval, 3);
|
|
@ -2,14 +2,18 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
It is a Syntax Error if LeftHandSideExpression is neither an
|
||||
ObjectLiteral nor an ArrayLiteral and
|
||||
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is
|
||||
false.
|
||||
template: syntax
|
||||
es6id: 12.14.5.1
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
([arguments] = []);
|
||||
//- elems
|
||||
[arguments]
|
||||
//- vals
|
||||
[]
|
|
@ -2,32 +2,36 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of an
|
||||
AssignmentElement within a generator function body, it behaves as a
|
||||
YieldExpression.
|
||||
template: default
|
||||
es6id: 12.14.5.4
|
||||
features: [generators]
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var value = [33];
|
||||
var x = {};
|
||||
var assignmentResult, iterationResult, iter;
|
||||
var iterationResult, iter;
|
||||
|
||||
iter = (function*() {
|
||||
assignmentResult = [ x[yield] ] = value;
|
||||
//- elems
|
||||
[ x[yield] ]
|
||||
//- vals
|
||||
[33]
|
||||
//- teardown
|
||||
}());
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert.sameValue(assignmentResult, undefined);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, false);
|
||||
assert.sameValue(x.prop, undefined);
|
||||
|
||||
iterationResult = iter.next('prop');
|
||||
|
||||
assert.sameValue(assignmentResult, value);
|
||||
assert.sameValue(iterationResult.value, undefined);
|
||||
assert.sameValue(iterationResult.done, true);
|
||||
assert.sameValue(x.prop, 33);
|
|
@ -2,13 +2,17 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of an
|
||||
AssignmentElement and outside of a generator function body, it behaves as
|
||||
an IdentifierReference.
|
||||
template: syntax
|
||||
es6id: 12.14.5.4
|
||||
flags: [onlyStrict]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
[ x[yield] ] = [];
|
||||
//- elems
|
||||
[ x[yield] ]
|
||||
//- vals
|
||||
[]
|
|
@ -2,20 +2,21 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
When a `yield` token appears within the DestructuringAssignmentTarget of an
|
||||
AssignmentElement outside of a generator function body, it behaves as an
|
||||
IdentifierReference.
|
||||
template: default
|
||||
es6id: 12.14.5.4
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var value = [33];
|
||||
//- setup
|
||||
var yield = 'prop';
|
||||
var x = {};
|
||||
var result;
|
||||
|
||||
result = [ x[yield] ] = value;
|
||||
|
||||
assert.sameValue(result, value);
|
||||
//- elems
|
||||
[ x[yield] ]
|
||||
//- vals
|
||||
[33]
|
||||
//- body
|
||||
assert.sameValue(x.prop, 33);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned during evaluation of elision
|
||||
desc: Abrupt completion returned during evaluation of elision
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -16,10 +16,12 @@ info: |
|
|||
IteratorClose(iterator, status).
|
||||
ii. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -44,9 +46,12 @@ iterable[Symbol.iterator] = function() {
|
|||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 2);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from IteratorClose
|
||||
desc: Abrupt completion returned from IteratorClose
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -16,10 +16,12 @@ info: |
|
|||
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
|
||||
status).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -40,10 +42,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 2);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
|
@ -26,10 +26,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var x;
|
||||
var nextCount = 0;
|
||||
|
@ -47,7 +49,9 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[ x , , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[ x , , ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: IteratorClose not invoked when elision exhausts the iterator
|
||||
desc: IteratorClose not invoked when elision exhausts the iterator
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -17,10 +17,12 @@ info: |
|
|||
status).
|
||||
9. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -38,8 +40,10 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x , , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ x , , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 2);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: IteratorClose invoked when elision does not exhaust the iterator
|
||||
desc: IteratorClose invoked when elision does not exhaust the iterator
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -22,10 +22,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -50,9 +52,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x , , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ x , , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 2);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from GetIterator
|
||||
desc: Abrupt completion returned from GetIterator
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -9,16 +9,20 @@ info: |
|
|||
1. Let iterator be GetIterator(value).
|
||||
2. ReturnIfAbrupt(iterator).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
var x;
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from IteratorClose
|
||||
desc: Abrupt completion returned from IteratorClose
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -16,10 +16,12 @@ info: |
|
|||
status).
|
||||
b. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -40,10 +42,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
|
@ -26,10 +26,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var x;
|
||||
var nextCount = 0;
|
||||
|
@ -47,7 +49,9 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[ x , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not invoked when evaluation of AssignmentElementList
|
||||
exhausts the iterator
|
||||
info: |
|
||||
|
@ -18,10 +18,12 @@ info: |
|
|||
status).
|
||||
b. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -41,8 +43,10 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is invoked when evaluation of AssignmentElementList completes
|
||||
without exhausting the iterator
|
||||
info: |
|
||||
|
@ -24,10 +24,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -51,9 +53,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is invoked when evaluation of AssignmentElementList returns
|
||||
a "return" completion and the iterator has not been marked as "done"
|
||||
info: |
|
||||
|
@ -24,10 +24,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
var iterable = {};
|
||||
|
@ -44,8 +46,13 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ {}[yield] , ] = iterable;
|
||||
unreachable += 1;
|
||||
//- elems
|
||||
[ {}[yield] , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
|
@ -26,10 +26,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
return: function() {
|
||||
|
@ -42,7 +44,11 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ {}[yield] , ] = iterable;
|
||||
//- elems
|
||||
[ {}[yield] , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is invoked when evaluation of AssignmentElementList returns
|
||||
a "return" completion and the iterator has not been marked as "done"
|
||||
info: |
|
||||
|
@ -25,10 +25,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
var thisValue = null;
|
||||
|
@ -49,8 +51,13 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ {}[yield] , ] = iterable;
|
||||
//- elems
|
||||
[ {}[yield] , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
};
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is invoked when evaluation of AssignmentElementList returns
|
||||
a "throw" completion and the iterator has not been marked as "done"
|
||||
info: |
|
||||
|
@ -23,10 +23,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -50,9 +52,13 @@ iterable[Symbol.iterator] = function() {
|
|||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ {}[thrower()] , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ {}[thrower()] , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not invoked when evaluation of AssignmentElementList
|
||||
returns an abrupt completion and the iterator has been marked as "done"
|
||||
info: |
|
||||
|
@ -18,10 +18,12 @@ info: |
|
|||
status).
|
||||
b. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -41,10 +43,12 @@ iterable[Symbol.iterator] = function() {
|
|||
return iterator;
|
||||
};
|
||||
var x;
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is invoked when evaluation of AssignmentElementList returns
|
||||
a "throw" completion and the iterator has not been marked as "done"
|
||||
info: |
|
||||
|
@ -24,10 +24,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -50,11 +52,13 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ {}[thrower()] , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ {}[thrower()] , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not called when rest element evaluation has exhausted the
|
||||
iterator
|
||||
info: |
|
||||
|
@ -17,10 +17,12 @@ info: |
|
|||
status).
|
||||
9. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -37,9 +39,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ x , ...y ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ x , ...y ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 2, 'nextCount');
|
||||
assert.sameValue(returnCount, 0, 'returnCount');
|
||||
assert.sameValue(x, 1, 'x');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when AssignmentRestEvaluation produces a "return"
|
||||
completion due to reference evaluation
|
||||
info: |
|
||||
|
@ -24,10 +24,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
|
@ -51,8 +53,13 @@ iterable[Symbol.iterator] = function() {
|
|||
return iterator;
|
||||
};
|
||||
function* g() {
|
||||
[ x , ...{}[yield] ] = iterable;
|
||||
//- elems
|
||||
[ x , ...{}[yield] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
|
@ -23,10 +23,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var iterable = {};
|
||||
var x;
|
||||
|
@ -47,7 +49,11 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ x , ...{}[yield] ] = iterable;
|
||||
//- elems
|
||||
[ x , ...{}[yield] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when AssignmentRestEvaluation produces a "return"
|
||||
completion due to reference evaluation
|
||||
info: |
|
||||
|
@ -24,10 +24,12 @@ info: |
|
|||
7. If completion.[[type]] is throw, return Completion(completion).
|
||||
8. If innerResult.[[type]] is throw, return Completion(innerResult).
|
||||
features: [Symbol.iterator, generators]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var unreachable = 0;
|
||||
|
@ -55,8 +57,13 @@ iterable[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
function* g() {
|
||||
[ x , ...{}[yield] ] = iterable;
|
||||
//- elems
|
||||
[ x , ...{}[yield] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
unreachable += 1;
|
||||
//- teardown
|
||||
}
|
||||
|
||||
iter = g();
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when AssignmentRestEvaluation produces a "throw"
|
||||
completion due to reference evaluation
|
||||
info: |
|
||||
|
@ -22,10 +22,12 @@ info: |
|
|||
[...]
|
||||
7. If completion.[[type]] is throw, return Completion(completion)
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var x;
|
||||
|
@ -51,10 +53,12 @@ var thrower = function() {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ...{}[thrower()] ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ...{}[thrower()] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned during iteration for rest element
|
||||
desc: Abrupt completion returned during iteration for rest element
|
||||
info: |
|
||||
ArrayAssignmentPattern :
|
||||
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
||||
|
@ -15,10 +15,12 @@ info: |
|
|||
status).
|
||||
9. Return Completion(status).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -42,10 +44,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ...x ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ...x ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 2);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when AssignmentRestEvaluation produces a "throw"
|
||||
completion due to reference evaluation
|
||||
info: |
|
||||
|
@ -23,10 +23,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -52,11 +54,13 @@ var thrower = function() {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ x , ...{}[thrower()] ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ x , ...{}[thrower()] ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not called when iteration produces an abrupt completion
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ Elision ]
|
||||
|
@ -12,10 +12,12 @@ info: |
|
|||
result).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -31,10 +33,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,22 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from GetIterator
|
||||
desc: Abrupt completion returned from GetIterator
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ Elision ]
|
||||
|
||||
1. Let iterator be GetIterator(value).
|
||||
2. ReturnIfAbrupt(iterator).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
Abrupt completion returned from IteratorClose
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ Elision ]
|
||||
|
@ -12,10 +12,12 @@ info: |
|
|||
result).
|
||||
6. Return result.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -34,10 +36,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[ , ] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ Elision ]
|
||||
|
@ -21,10 +21,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var nextCount = 0;
|
||||
var iterator = {
|
||||
|
@ -41,7 +43,9 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[ , ] = iterable;
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is not called when iteration has exhausted the iterator
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ Elision ]
|
||||
|
@ -12,10 +12,12 @@ info: |
|
|||
result).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -32,8 +34,10 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose is called when assignment evaluation has not exhausted the
|
||||
iterator
|
||||
info: |
|
||||
|
@ -19,10 +19,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -45,9 +47,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[ , ] = iterable;
|
||||
|
||||
//- elems
|
||||
[ , ]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 1);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -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
|
||||
[]
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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'
|
|
@ -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
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from IteratorClose
|
||||
desc: Abrupt completion returned from IteratorClose
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ ]
|
||||
|
||||
|
@ -9,10 +9,12 @@ info: |
|
|||
2. ReturnIfAbrupt(iterator).
|
||||
3. Return IteratorClose(iterator, NormalCompletion(empty)).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var iterable = {};
|
||||
|
@ -29,10 +31,12 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[] = iterable;
|
||||
});
|
||||
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[]
|
||||
//- vals
|
||||
iterable
|
||||
//- teardown
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
desc: >
|
||||
IteratorClose throws a TypeError when `return` returns a non-Object value
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ ]
|
||||
|
@ -19,10 +19,12 @@ info: |
|
|||
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
|
||||
exception.
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
var iterator = {
|
||||
next: function() {
|
||||
|
@ -35,7 +37,9 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[] = iterable;
|
||||
});
|
||||
//- error
|
||||
TypeError
|
||||
//- elems
|
||||
[]
|
||||
//- vals
|
||||
iterable
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Iterator is closed without iterating
|
||||
desc: Iterator is closed without iterating
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ ]
|
||||
|
||||
|
@ -15,10 +15,12 @@ info: |
|
|||
6. Let innerResult be Call(return, iterator, « »).
|
||||
[...]
|
||||
features: [Symbol.iterator]
|
||||
template: default
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var nextCount = 0;
|
||||
var returnCount = 0;
|
||||
var thisValue = null;
|
||||
|
@ -39,9 +41,11 @@ var iterator = {
|
|||
iterable[Symbol.iterator] = function() {
|
||||
return iterator;
|
||||
};
|
||||
|
||||
[] = iterable;
|
||||
|
||||
//- elems
|
||||
[]
|
||||
//- vals
|
||||
iterable
|
||||
//- body
|
||||
assert.sameValue(nextCount, 0);
|
||||
assert.sameValue(returnCount, 1);
|
||||
assert.sameValue(thisValue, iterator, 'correct `this` value');
|
|
@ -1,22 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Abrupt completion returned from GetIterator
|
||||
desc: Abrupt completion returned from GetIterator
|
||||
info: |
|
||||
ArrayAssignmentPattern : [ ]
|
||||
|
||||
1. Let iterator be GetIterator(value).
|
||||
2. ReturnIfAbrupt(iterator).
|
||||
features: [Symbol.iterator]
|
||||
template: error
|
||||
es6id: 12.14.5.2
|
||||
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[] = iterable;
|
||||
});
|
||||
//- error
|
||||
Test262Error
|
||||
//- elems
|
||||
[]
|
||||
//- vals
|
||||
iterable
|
|
@ -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
|
||||
[]
|
|
@ -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
|
|
@ -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
Loading…
Reference in New Issue