Merge pull request #1039 from rwaldron/dstr-assignment_for-await-of

[WIP] for-await-of: dstr-assignment, templates & cases
This commit is contained in:
Rick Waldron 2017-05-31 15:46:40 -04:00 committed by GitHub
commit 60a6a7c81e
211 changed files with 7266 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
If the Initializer is present and v is undefined, the Initializer should be
evaluated and the result assigned to the target reference.
template: default
---*/
//- setup
let v2, vNull, vHole, vUndefined, vOob;
//- elems
[v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14]
//- vals
[2, null, , undefined]
//- body
assert.sameValue(v2, 2);
assert.sameValue(vNull, null);
assert.sameValue(vHole, 12);
assert.sameValue(vUndefined, 13);
assert.sameValue(vOob, 14);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The Initializer should only be evaluated if v is undefined.
template: default
---*/
//- setup
let flag1 = false, flag2 = false;
let _;
//- elems
[ _ = flag1 = true, _ = flag2 = true ]
//- vals
[14]
//- body
assert.sameValue(flag1, false);
assert.sameValue(flag2, true);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,34 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (ArrowFunction)
template: default
info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
[...]
7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
includes: [propertyHelper.js]
---*/
//- setup
let arrow;
//- elems
[ arrow = () => {} ]
//- vals
[]
//- body
assert.sameValue(arrow.name, 'arrow');
verifyNotEnumerable(arrow, 'name');
verifyNotWritable(arrow, 'name');
verifyConfigurable(arrow, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,40 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (ClassExpression)
template: default
info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
[...]
7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [class]
---*/
//- setup
let xCls, cls, xCls2;
//- elems
[ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ]
//- vals
[]
//- body
assert(xCls.name !== 'xCls');
assert(xCls2.name !== 'xCls2');
assert.sameValue(cls.name, 'cls');
verifyNotEnumerable(cls, 'name');
verifyNotWritable(cls, 'name');
verifyConfigurable(cls, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Assignment of function `name` attribute (CoverParenthesizedExpression)
template: default
info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
[...]
7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
includes: [propertyHelper.js]
---*/
//- setup
let xCover, cover;
//- elems
[ xCover = (0, function() {}), cover = (function() {}) ]
//- vals
[]
//- body
assert(xCover.name !== 'xCover');
assert.sameValue(cover.name, 'cover');
verifyNotEnumerable(cover, 'name');
verifyNotWritable(cover, 'name');
verifyConfigurable(cover, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (FunctionExpression)
template: default
info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
[...]
7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [class]
---*/
//- setup
let xFnexp, fnexp;
//- elems
[ xFnexp = function x() {}, fnexp = function() {} ]
//- vals
[]
//- body
assert(xFnexp.name !== 'xFnexp');
assert.sameValue(fnexp.name, 'fnexp');
verifyNotEnumerable(fnexp, 'name');
verifyNotWritable(fnexp, 'name');
verifyConfigurable(fnexp, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (GeneratorExpression)
template: default
info: >
AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
[...]
7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [generators]
---*/
//- setup
let xGen, gen;
//- elems
[ xGen = function* x() {}, gen = function*() {} ]
//- vals
[]
//- body
assert.notSameValue(xGen.name, 'xGen');
assert.sameValue(gen.name, 'gen');
verifyNotEnumerable(gen, 'name');
verifyNotWritable(gen, 'name');
verifyConfigurable(gen, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The Initializer in an AssignmentElement may be an `in` expression.
template: default
---*/
//- setup
let x;
//- elems
[ x = 'x' in {} ]
//- vals
[]
//- body
assert.sameValue(x, false);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Value retrieval of Initializer obeys `let` semantics.
template: default
es6id: 12.14.5.3
features: [let]
---*/
//- setup
let x;
//- elems
[ x = y ]
//- vals
[]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(constructor, ReferenceError);
}).then($DONE, $DONE);
let y;

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Initializer values should be assigned in left-to-right order.
template: default
---*/
//- setup
let x = 0;
let a, b;
//- elems
[ a = x += 1, b = x *= 2 ]
//- vals
[]
//- body
assert.sameValue(a, 1);
assert.sameValue(b, 2);
assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern.
template: default
flags: [noStrict]
---*/
//- setup
let argument, eval;
//- elems
[arguments = 4, eval = 5]
//- vals
[]
//- body
assert.sameValue(arguments, 4);
assert.sameValue(eval, 5);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of an
AssignmentElement within a generator function body, it behaves as a
YieldExpression.
template: async-generator
es6id: 12.14.5.4
features: [generators]
---*/
//- setup
let value = [];
let x;
//- elems
[ x = yield ]
//- vals
[]
//- teardown
iter.next().then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, false);
assert.sameValue(x, undefined);
iter.next(4).then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, true);
assert.sameValue(x, 4);
}, $DONE).then($DONE, $DONE);
}, $DONE).catch($DONE);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of an AssignmentElement
outside of a generator function body, it behaves as an IdentifierReference.
template: error-async-function-syntax
es6id: 12.14.5.4
flags: [onlyStrict]
negative:
phase: early
type: SyntaxError
---*/
//- elems
[ x = yield ]
//- vals
[]

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of an AssignmentElement
outside of a generator function body, it behaves as an IdentifierReference.
template: async-function
es6id: 12.14.5.4
flags: [noStrict]
---*/
//- setup
let yield = 4;
let x;
//- elems
[ x = yield ]
//- vals
[]
//- body
assert.sameValue(x, 4);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned from GetIterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
1. Let iterator be ? GetIterator(value).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let iterable = {
[Symbol.iterator]() {
throw new Test262Error();
}
};
let _;
//- elems
[ _ ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,47 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned from IteratorClose
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let _;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
throw new Test262Error();
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ _ ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,55 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
5. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[Type]] is throw, return Completion(completion).
7. If innerResult.[[Type]] is throw, return Completion(innerResult).
8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let _;
let nextCount = 0;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ _ ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,48 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when assignment evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
5. Return result.
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let _;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ _ ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
//- teardown
iter.next().then(() => {
assert.sameValue(iterCount, 1);
}).then($DONE, $DONE);

View File

@ -0,0 +1,62 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when assignment evaluation has not exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
5. Return result.
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: default
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thisValue = null;
let args = null;
let _;
let iterable = {};
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
//- elems
[ _ ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,49 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
5. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[Type]] is throw, return Completion(completion).
7. If innerResult.[[Type]] is throw, return Completion(innerResult).
8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let unreachable = 0;
let iterator = {
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ {}[yield] ]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(unreachable, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,46 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when iteration produces an abrupt completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
5. Return result.
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let iterator = {
next() {
nextCount += 1;
throw new Test262Error();
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
let _;
//- elems
[ x ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
}).then($DONE, $DONE);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
or an ArrayLiteral and if the lexical token sequence matched by
LeftHandSideExpression cannot be parsed with no tokens left over using
AssignmentPattern as the goal symbol.
template: error-async-function-syntax
es6id: 12.14.5.1
negative:
phase: early
type: SyntaxError
---*/
//- elems
[[(x, y)]]
//- vals
[[]]

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the value is
`null`, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let _;
//- elems
[[ _ ]]
//- vals
[null]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the value is a
"hole", a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let _;
//- elems
[[ _ ]]
//- vals
[ , ]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the value is
`undefined`, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let _;
//- elems
[[ x ]]
//- vals
[undefined]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and no value is
defined, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let _;
//- elems
[[ x ]]
//- vals
[]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment and within a generator function body, it
behaves as a YieldExpression.
template: async-generator
es6id: 12.14.5.3
features: [generators]
---*/
//- setup
let value = [[22]];
let x = {};
//- elems
[[x[yield]]]
//- vals
value
//- teardown
iter.next().then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, false);
assert.sameValue(x.prop, undefined);
iter.next('prop').then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, true);
assert.sameValue(x.prop, 22);
}, $DONE).then($DONE, $DONE);
}, $DONE).catch($DONE);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference.
template: error-async-function-syntax
es6id: 12.14.5.3
flags: [onlyStrict]
negative:
phase: early
type: SyntaxError
---*/
//- elems
[[x[yield]]]
//- vals
[[]]

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference.
template: async-function
flags: [noStrict]
---*/
//- setup
let yield = 'prop';
let x = {};
//- elems
[[x[yield]]]
//- vals
[[22]]
//- body
assert.sameValue(x.prop, 22);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: async-function
---*/
//- setup
let x;
//- elems
[[x]]
//- vals
[[1]]
//- body
assert.sameValue(x, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral
or an ArrayLiteral and if the lexical token sequence matched by
LeftHandSideExpression cannot be parsed with no tokens left over using
AssignmentPattern as the goal symbol.
template: error-async-function-syntax
es6id: 12.14.5.1
negative:
phase: early
type: SyntaxError
---*/
//- elems
[{ get x() {} }]
//- vals
[{}]

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal and the value is
`null`, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x;
//- elems
[{ x }]
//- vals
[null]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal and the value is a
"hole", a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x;
//- elems
[{ x }]
//- vals
[ , ]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal and the value is
`undefined`, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x;
//- elems
[{ x }]
//- vals
[undefined]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal and no value is
defined, a TypeError should be thrown.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x;
//- elems
[{ x }]
//- vals
[]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of a nested
destructuring assignment and within a generator function body, it behaves
as a YieldExpression.
template: async-generator
---*/
//- setup
let x;
//- elems
[{ x = yield }]
//- vals
[{}]
//- teardown
iter.next().then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, false);
assert.sameValue(x, undefined);
iter.next(4).then(result => {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, true);
assert.sameValue(x, 4);
}, $DONE).then($DONE, $DONE);
}, $DONE).catch($DONE);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of a nested
destructuring assignment outside of a generator function body, it behaves
as a IdentifierReference.
template: error-async-function-syntax
es6id: 12.14.5.3
flags: [onlyStrict]
negative:
phase: early
type: SyntaxError
---*/
//- elems
[{ x = yield }]
//- vals
[{}]

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of a nested
destructuring assignment outside of a generator function body, it behaves
as an IdentifierReference.
template: async-function
flags: [noStrict]
---*/
//- setup
let yield = 2;
let x;
//- elems
[{ x = yield }]
//- vals
[{}]
//- body
assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal, it should be
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: default
---*/
//- setup
let x;
//- elems
[{ x }]
//- vals
[{ x: 2 }]
//- body
assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The assignment target should obey `const` semantics.
template: default
es6id: 12.14.5.3
features: [const]
---*/
//- setup
const c = null;
//- elems
[ c ]
//- vals
[1]

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The assignment target should obey `let` semantics.
template: default
es6id: 12.14.5.3
features: [let]
---*/
//- elems
[ x ]
//- vals
[]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, ReferenceError);
}).then($DONE, $DONE);
let x;

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
If the DestructuringAssignmentTarget of an AssignmentElement is a
PropertyReference, it should not be evaluated.
template: default
---*/
//- setup
let x, setValue;
x = {
get y() {
$ERROR('The property should not be accessed.');
},
set y(val) {
setValue = val;
}
};
//- elems
[x.y]
//- vals
[23]
//- body
assert.sameValue(setValue, 23);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Any error raised as a result of setting the value should be forwarded to
the runtime.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = {
set y(val) {
throw new Test262Error();
}
};
//- elems
[x.y]
//- vals
[23]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The DestructuringAssignmentTarget of an AssignmentElement may be a
PropertyReference.
template: default
---*/
//- setup
let x = {};
//- elems
[x.y]
//- vals
[4]
//- body
assert.sameValue(x.y, 4);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Outside of strict mode, if the the assignment target is an unresolvable
reference, a new `var` binding should be created in the environment record.
template: default
flags: [noStrict]
---*/
//- elems
[ unresolvable ]
//- vals
[]
//- body
assert.sameValue(unresolvable, undefined);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
In strict mode, if the the assignment target is an unresolvable reference,
a ReferenceError should be thrown.
template: default
es6id: 12.14.5.3
flags: [onlyStrict]
---*/
//- elems
[ unresolvable ]
//- vals
[]
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, ReferenceError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern.
template: async-function
---*/
//- setup
let x, y, z;
//- elems
[x, y, z]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x, 1);
assert.sameValue(y, 2);
assert.sameValue(z, 3);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Identifiers that appear as the DestructuringAssignmentTarget in an
AssignmentElement should take on the iterated value corresponding to their
position in the ArrayAssignmentPattern.
template: async-generator
flags: [noStrict]
---*/
//- setup
let argument, eval;
//- elems
[arguments, eval]
//- vals
[2, 3]
//- body
assert.sameValue(arguments, 2);
assert.sameValue(eval, 3);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
It is a Syntax Error if LeftHandSideExpression is neither an
ObjectLiteral nor an ArrayLiteral and
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is
false.
template: error-async-function-syntax
es6id: 12.14.5.1
flags: [onlyStrict]
negative:
phase: early
type: SyntaxError
---*/
//- elems
[arguments]
//- vals
[]

View File

@ -0,0 +1,35 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement within a generator function body, it behaves as a
YieldExpression.
template: async-generator
features: [generators]
---*/
//- setup
let value = [33];
let x = {};
let iterationResult;
//- elems
[ x[yield] ]
//- vals
[33]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined);
iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 33);
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement and outside of a generator function body, it behaves as
an IdentifierReference.
template: error-async-function-syntax
es6id: 12.14.5.4
flags: [onlyStrict]
negative:
phase: early
type: SyntaxError
---*/
//- elems
[ x[yield] ]
//- vals
[]

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of an
AssignmentElement outside of a generator function body, it behaves as an
IdentifierReference.
template: async-function
flags: [noStrict]
---*/
//- setup
let yield = 'prop';
let x = {};
//- elems
[ x[yield] ]
//- vals
[33]
//- body
assert.sameValue(x.prop, 33);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,63 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned during evaluation of elision
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
i. If iteratorRecord.[[done]] is false, return
IteratorClose(iterator, status).
ii. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let x;
let iterator = {
next() {
nextCount += 1;
if (nextCount === 2) {
throw new Test262Error();
}
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , , ]
//- vals
iterable
//- teardown
iter.next().then(() => {
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);
}, $DONE);

View File

@ -0,0 +1,60 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned from IteratorClose
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
[...]
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let x;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
throw new Test262Error();
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , , ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
[...]
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult).
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception.
features: [Symbol.iterator]
template: default
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let x;
let nextCount = 0;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- error
TypeError
//- elems
[ x , , ]
//- vals
iterable

View File

@ -0,0 +1,57 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: IteratorClose not invoked when elision exhausts the iterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
5. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
[...]
7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
9. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let x;
let iterator = {
next() {
nextCount += 1;
return { done: nextCount > 1 };
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,72 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: IteratorClose invoked when elision does not exhaust the iterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
5. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
[...]
7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thisValue = null;
let args = null;
let x;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned from GetIterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let iterable = {
[Symbol.iterator]() {
throw new Test262Error();
}
};
let x;
//- elems
[ x , ]
//- vals
iterable
//- teardown
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion returned from IteratorClose
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
b. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thrower = function() {
throw new Test262Error();
};
let x;
let iterator = {
next() {
nextCount += 1;
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
throw new Test262Error();
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- error
Test262Error
//- elems
[ x , ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,65 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
b. Return Completion(status).
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
8. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception.
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let x;
let nextCount = 0;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- error
TypeError
//- elems
[ x , ]
//- vals
iterable
//- teardown
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,57 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not invoked when evaluation of AssignmentElementList
exhausts the iterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
b. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thrower = function() {
throw new Test262Error();
};
let x;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,70 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is invoked when evaluation of AssignmentElementList completes
without exhausting the iterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
b. Return Completion(status).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thisValue = null;
let args = null;
let x;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,60 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns
a "return" completion and the iterator has not been marked as "done"
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
b. Return Completion(status).
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let returnCount = 0;
let unreachable = 0;
let iterator = {
return() {
returnCount += 1;
throw new Test262Error();
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ {}[yield] , ]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,55 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
b. Return Completion(status).
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
8. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception.
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let iterator = {
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ {}[yield] , ]
//- vals
iterable
//- teardown
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);

View File

@ -0,0 +1,68 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is invoked when evaluation of AssignmentElementList returns
a "return" completion and the iterator has not been marked as "done"
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
4. If status is an abrupt completion, then
a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
b. Return Completion(status).
7.4.6 IteratorClose( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let returnCount = 0;
let unreachable = 0;
let thisValue = null;
let args = null;
let iterator = {
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ {}[yield] , ]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.return(888).then(result => {
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
assert.sameValue(result.value, 888);
assert(result.done, 'Iterator correctly closed');
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
}).then($DONE, $DONE);

View File

@ -0,0 +1,58 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not invoked when evaluation of AssignmentElementList
returns an abrupt completion and the iterator has been marked as "done"
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
4. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument.
5. If status is an abrupt completion, then
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
b. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let iterable = {};
let thrower = function() {
throw new Test262Error();
};
let iterator = {
next() {
nextCount += 1;
throw new Test262Error();
},
return() {
returnCount += 1;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
let x;
//- error
Test262Error
//- elems
[ x , ]
//- vals
iterable
//- teardown
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
assert.sameValue(iterCount, 0);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,55 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when rest element evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If AssignmentRestElement is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
with iteratorRecord as the argument.
7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
8. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let x, y;
let iterator = {
next() {
nextCount += 1;
return { value: nextCount, done: nextCount > 1 };
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , ...y ]
//- vals
iterable
//- teardown
iter.next().then(() => {
iter.return().then(() => {
assert.sameValue(nextCount, 2, 'nextCount');
assert.sameValue(returnCount, 0, 'returnCount');
assert.sameValue(x, 1, 'x');
assert.sameValue(y.length, 0, 'y.length');
}).then($DONE, $DONE);
}).then($DONE, $DONE);

View File

@ -0,0 +1,69 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when AssignmentRestEvaluation produces a "return"
completion due to reference evaluation
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If AssignmentRestElement is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
with iteratorRecord as the argument.
7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
8. Return Completion(status).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let unreachable = 0;
let x;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
throw new Test262Error();
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , ...{}[yield] ]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.next().then(() => {
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);
}).then($DONE, $DONE);

View File

@ -0,0 +1,60 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If AssignmentRestElement is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
with iteratorRecord as the argument.
7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
8. Return Completion(status).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
6. If completion.[[type]] is throw, return Completion(completion).
7. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let x;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ x , ...{}[yield] ]
//- vals
iterable
//- teardown
iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(nextCount, 1);
assert.sameValue(constructor, Test262Error);
}).then($DONE, $DONE);

View File

@ -0,0 +1,49 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when iteration has exhausted the iterator
info: |
ArrayAssignmentPattern : [ Elision ]
1. Let iterator be ? GetIterator(value).
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,67 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when assignment evaluation has not exhausted the
iterator
info: |
ArrayAssignmentPattern : [ Elision ]
1. Let iterator be ? GetIterator(value).
[...]
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
[...]
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thisValue = null;
let args = null;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ , ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An ArrayAssignmentPattern containing only Elisions requires iterable values
template: default
---*/
//- elems
[,]
//- vals
[]
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An ArrayAssignmentPattern containing only Elisions requires iterable values
template: default
---*/
//- elems
[,]
//- vals
'string literal'
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Iterator is closed without iterating
info: |
ArrayAssignmentPattern : [ ]
1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator).
3. Return IteratorClose(iterator, NormalCompletion(empty)).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let thisValue = null;
let args = null;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[]
//- vals
iterable
//- body
assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An ArrayAssignmentPattern without an AssignmentElementList requires
iterable values.
template: default
---*/
//- elems
[]
//- vals
[]
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An ArrayAssignmentPattern without an AssignmentElementList requires
iterable values.
template: default
---*/
//- elems
[]
//- vals
'string literal'
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An AssignmentRestElement following an AssignmentElement consumes all
remaining iterable values.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x, y;
//- elems
[x, ...y]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x, 1);
assert.sameValue(y.length, 2);
assert.sameValue(y[0], 2);
assert.sameValue(y[1], 3);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
An AssignmentRestElement following an elision consumes all remaining
iterable values.
template: default
---*/
//- setup
let x;
//- elems
[, ...x]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x.length, 2);
assert.sameValue(x[0], 2);
assert.sameValue(x[1], 3);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
ArrayAssignmentPattern may include elisions at any position preceeding a
AssignmentRestElement in a AssignmentElementList.
template: default
---*/
//- setup
let x, y;
//- elems
[, , x, , ...y]
//- vals
[1, 2, 3, 4, 5, 6]
//- body
assert.sameValue(x, 3);
assert.sameValue(y.length, 2);
assert.sameValue(y[0], 5);
assert.sameValue(y[1], 6);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,50 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when assignment evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
4. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
with iteratorRecord as the argument.
5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
6. Return result.
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let x;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ ...x ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,35 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
In the presense of an AssignmentRestElement, value iteration exhausts the
iterable value;
template: default
es6id: 12.14.5.3
features: [generators]
---*/
//- setup
let count = 0;
let g = function*() {
count += 1;
yield;
count += 1;
yield;
count += 1;
}
let x;
//- elems
[...x]
//- vals
g()
//- body
assert.sameValue(count, 3);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Reference is evaluated during assignment
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
4. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
with iteratorRecord as the argument.
5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
ArrayLiteral, then
a. Let lref be the result of evaluating DestructuringAssignmentTarget.
b. ReturnIfAbrupt(lref).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let nextCount = 0;
let returnCount = 0;
let iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
let obj = {};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[...obj['a' + 'b']]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
assert(!!obj.ab);
assert.sameValue(obj.ab.length, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable
emits `null` as the only value, an array with a single `null` element
should be used as the value of the nested DestructuringAssignment.
template: default
---*/
//- setup
let x, y;
//- elems
[...[x, y]]
//- vals
[null]
//- body
assert.sameValue(x, null);
assert.sameValue(y, undefined);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable is
an array with a "hole", an array with a single `undefined` element should
be used as the value of the nested DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
//- elems
[...[x]]
//- vals
[ , ]
//- body
assert.sameValue(x, undefined);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable
emits `undefined` as the only value, an array with a single `undefined`
element should be used as the value of the nested DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
//- elems
[...[x]]
//- vals
[undefined]
//- body
assert.sameValue(x, undefined);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable is
emits no values, an empty array should be used as the value of the nested
DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
//- elems
[...[x]]
//- vals
[]
//- body
assert.sameValue(x, undefined);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment and within a generator function body, it
should behave as a YieldExpression.
template: async-generator
features: [generators]
---*/
//- setup
let x = {};
//- elems
[...[x[yield]]]
//- vals
[86]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined);
iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 86);
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment and outside of a generator function body,
it should behave as an IdentifierExpression.
template: async-function
flags: [noStrict]
---*/
//- setup
let yield = 'prop';
let x = {};
//- elems
[...[x[yield]]]
//- vals
[86]
//- body
assert.sameValue(x.prop, 86);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x;
//- elems
[...[x]]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal and the iterable
emits `null` as the only value, an array with a single `null` element
should be used as the value of the nested DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x, length;
//- elems
[...{ 0: x, length }]
//- vals
[null]
//- body
assert.sameValue(x, null);
assert.sameValue(length, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable is
an array with a "hole", an array with a single `undefined` element should
be used as the value of the nested DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy
let length;
//- elems
[...{ 0: x, length }]
//- vals
[ , ]
//- body
assert.sameValue(x, undefined);
assert.sameValue(length, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an array literal and the iterable
emits `undefined` as the only value, an array with a single `undefined`
element should be used as the value of the nested DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy
let length;
//- elems
[...{ 0: x, length }]
//- vals
[undefined]
//- body
assert.sameValue(x, undefined);
assert.sameValue(length, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an obect literal and the iterable is
emits no values, an empty array should be used as the value of the nested
DestructuringAssignment.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy
let length;
//- elems
[...{ 0: x, length }]
//- vals
[]
//- body
assert.sameValue(x, undefined);
assert.sameValue(length, 0);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of a nested
destructuring assignment and within a generator function body, it should
behave as a YieldExpression.
template: async-generator
features: [generators]
---*/
//- setup
let x;
//- elems
[...{ x = yield }]
//- vals
[{}]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x, undefined);
iter.next(4).then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x, 4);
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the Initializer of a nested
destructuring assignment and outside of a generator function body, it
should behave as an IdentifierExpression.
template: async-function
flags: [noStrict]
---*/
//- setup
let yield = 2;
let x;
//- elems
[...{ x = yield }]
//- vals
[{}]
//- body
assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal, it should be
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: default
---*/
//- setup
let x;
//- elems
[...{ 1: x }]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,34 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
If the DestructuringAssignmentTarget of an AssignmentElement is a
PropertyReference, it should not be evaluated.
template: default
es6id: 12.14.5.3
---*/
//- setup
let setValue;
let x = {
get y() {
$ERROR('The property should not be accessed.');
},
set y(val) {
setValue = val;
}
};
//- elems
[...x.y]
//- vals
[23, 45, 99]
//- body
assert.sameValue(setValue.length, 3);
assert.sameValue(setValue[0], 23);
assert.sameValue(setValue[1], 45);
assert.sameValue(setValue[2], 99);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
The DestructuringAssignmentTarget of an AssignmentElement may be a
PropertyReference.
template: default
es6id: 12.14.5.3
---*/
//- setup
let x = {};
//- elems
[...x.y]
//- vals
[4, 3, 2]
//- body
assert.sameValue(x.y.length, 3);
assert.sameValue(x.y[0], 4);
assert.sameValue(x.y[1], 3);
assert.sameValue(x.y[2], 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Outside of strict mode, if the the assignment target is an unresolvable
reference, a new `var` binding should be created in the environment record.
template: default
flags: [noStrict]
---*/
//- elems
[ ...unresolvable ]
//- vals
[]
//- body
assert.sameValue(unresolvable.length, 0);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of
an AssignmentRestElement and within the body of a generator function, it
should behave as a YieldExpression.
template: async-generator
features: [generators]
---*/
//- setup
let x = {};
//- elems
[...x[yield]]
//- vals
[33, 44, 55]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined);
iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop.length, 3);
assert.sameValue(x.prop[0], 33);
assert.sameValue(x.prop[1], 44);
assert.sameValue(x.prop[2], 55);
assert.sameValue(iterCount, 1);
}).then($DONE, $DONE);
});

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