for-await-of: dstr-assignment, default template

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
Rick Waldron 2017-05-03 16:31:35 -04:00
parent 2b0a8cc1c4
commit 9f3b85fb21
97 changed files with 3776 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
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);
//- 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
var flag1 = false, flag2 = false;
var _;
//- 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,36 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (ArrowFunction)
template: default
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js]
---*/
//- setup
var 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,42 @@
// 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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [class]
---*/
//- setup
var 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,39 @@
// Copyright (C) 2015 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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js]
---*/
//- setup
var 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,39 @@
// Copyright (C) 2015 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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [class]
---*/
//- setup
var xFn, fn;
//- elems
[ xFn = function x() {}, fn = function() {} ]
//- vals
[]
//- body
assert(xFn.name !== 'xFn');
assert.sameValue(fn.name, 'fn');
verifyNotEnumerable(fn, 'name');
verifyNotWritable(fn, 'name');
verifyConfigurable(fn, 'name');
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Assignment of function `name` attribute (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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js]
features: [generators]
---*/
//- setup
var 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
var 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,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
var x = 0;
var 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
var 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,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: >
IteratorClose is not called when assignment evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
6. Return result.
features: [Symbol.iterator]
template: default
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var _;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
//- elems
[ _ ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
//- 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: >
IteratorClose is called when assignment evaluation has not exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: default
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var _;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
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,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: >
When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference.
template: default
flags: [noStrict]
---*/
//- setup
var yield = 'prop';
var x = {};
//- elems
[[x[yield]]]
//- vals
[[22]]
//- body
assert.sameValue(x.prop, 22);

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 DestructuringAssignmentTarget is an array literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: default
---*/
//- setup
var x;
//- elems
[[x]]
//- vals
[[1]]
//- body
assert.sameValue(x, 1);

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
var 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);
}, $DONE).then($DONE, $DONE);
}, $DONE).catch($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: >
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
var yield = 2;
var 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
var 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,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
var 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,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
var 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,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
var 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
var 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,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: >
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
var value = [33];
var x = {};
var 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);
// TODO add iterCount
//
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,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
var yield = 'prop';
var 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,55 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: IteratorClose not invoked when elision exhausts the iterator
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).
9. Return Completion(status).
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var x;
var iterator = {
next() {
nextCount += 1;
return { done: nextCount > 1 };
},
return() {
returnCount += 1;
}
};
var 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,70 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: IteratorClose invoked when elision does not exhaust the iterator
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, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var x;
var 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 {};
}
};
var 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,57 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not invoked when evaluation of AssignmentElementList
exhausts the iterator
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
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thrower = function() {
throw new Test262Error();
};
var x;
var iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
var 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) 2016 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 ]
[...]
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).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var x;
var 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 {};
}
};
var 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,48 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when iteration has exhausted the iterator
info: |
ArrayAssignmentPattern : [ Elision ]
1. Let iterator be GetIterator(value).
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
return {};
}
};
var 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,66 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when assignment evaluation has not exhausted the
iterator
info: |
ArrayAssignmentPattern : [ Elision ]
1. Let iterator be GetIterator(value).
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
[...]
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var 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 {};
}
};
var 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) 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
---*/
//- 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) 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
---*/
//- 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) 2016 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 )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
var 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) 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
---*/
//- 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) 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
---*/
//- 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) 2015 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
var 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) 2015 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
var 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) 2015 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
var 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,54 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is not called when assignment evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
5. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
iteratorRecord as the argument
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
7. Return result.
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var x;
var iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
var iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[ ...x ]
//- vals
iterable
//- body
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
iter.next().then(() => {
assert.throws(Test262Error, () => iter.return());
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
})

View File

@ -0,0 +1,65 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when reference evaluation produces a "return"
completion
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
5. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
iteratorRecord as the argument
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
ArrayLiteral, then
a. Let lref be the result of evaluating DestructuringAssignmentTarget.
b. ReturnIfAbrupt(lref).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
function ReturnError() {}
var returnCount = 0;
var unreachable = 0;
var iterator = {
return() {
returnCount += 1;
throw new Test262Error();
}
};
var iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[...{}[yield]]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.next().then(() => {
assert.throws(Test262Error, () => iter.return());
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
}).then($DONE, $DONE);

View File

@ -0,0 +1,66 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
5. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
iteratorRecord as the argument
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
ArrayLiteral, then
a. Let lref be the result of evaluating DestructuringAssignmentTarget.
b. ReturnIfAbrupt(lref).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var iterable = {};
var iterator = {
return() {
return null;
}
};
var iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[...{}[yield]]
//- vals
iterable
//- teardown
iter.next().then(() => {
assert.throws(Test262Error, () => iter.return());
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
}).then($DONE, $DONE);

View File

@ -0,0 +1,83 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose is called when reference evaluation produces a "return"
completion
info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...]
5. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
iteratorRecord as the argument
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
ArrayLiteral, then
a. Let lref be the result of evaluating DestructuringAssignmentTarget.
b. ReturnIfAbrupt(lref).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult).
features: [Symbol.iterator, generators]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var returnCount = 0;
var unreachable = 0;
var thisValue = null;
var args = null;
var iterator = {
return() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
var iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- elems
[...{}[yield]]
//- vals
iterable
//- body
unreachable += 1;
//- teardown
iter.next().then(() => {
iter.return(444).then(result => {
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
assert.sameValue(result.value, 444);
assert(result.done, 'Iterator correctly closed');
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,30 @@
// Copyright (C) 2015 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
var count = 0;
var g = function*() {
count += 1;
yield;
count += 1;
yield;
count += 1;
}
var x;
//- elems
[...x]
//- vals
g()
//- body
assert.sameValue(count, 3);

View File

@ -0,0 +1,55 @@
// Copyright (C) 2016 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 ]
[...]
5. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
iteratorRecord as the argument
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
ArrayLiteral, then
a. Let lref be the result of evaluating DestructuringAssignmentTarget.
b. ReturnIfAbrupt(lref).
[...]
features: [Symbol.iterator]
template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
var nextCount = 0;
var returnCount = 0;
var iterator = {
next() {
nextCount += 1;
return { done: true };
},
return() {
returnCount += 1;
}
};
var obj = {};
var 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);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 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
var 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) 2015 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
var 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) 2015 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
var 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) 2015 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
var 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,34 @@
// Copyright (C) 2015 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
var value = [86];
var 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);
// TODO add iterCount
//
iter.next(86).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) 2015 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: default
flags: [noStrict]
---*/
//- setup
var yield = 'prop';
var 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) 2015 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
var 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) 2015 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
var 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,24 @@
// Copyright (C) 2015 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
var 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);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2015 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
var 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);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2015 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
var 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);

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: >
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
var x;
//- elems
[...{ x = yield }]
//- vals
[{}]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x, undefined);
// TODO add iterCount
//
iter.next(4).then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x, 4);
}).then($DONE, $DONE);
});

View File

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

View File

@ -0,0 +1,19 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
When DestructuringAssignmentTarget is an object literal, it should be
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment.
template: default
---*/
//- setup
var x;
//- elems
[...{ 1: x }]
//- vals
[1, 2, 3]
//- body
assert.sameValue(x, 2);

View File

@ -0,0 +1,30 @@
// 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 DestructuringAssignmentTarget of an AssignmentElement is a
PropertyReference, it should not be evaluated.
template: default
es6id: 12.14.5.3
---*/
//- setup
var setValue;
var 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);

View File

@ -0,0 +1,22 @@
// 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 DestructuringAssignmentTarget of an AssignmentElement may be a
PropertyReference.
template: default
es6id: 12.14.5.3
---*/
//- setup
var 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);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
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);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2015 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
var x = {};
//- elems
[...x[yield]]
//- vals
[33, 44, 55]
//- teardown
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined);
// TODO add iterCount
//
iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop.length, 3);
assert.sameValue(x.prop[0], 33);
assert.sameValue(x.prop[1], 44);
assert.sameValue(x.prop[2], 55);
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2015 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 outside of a generator function body, it should
behave as an IdentifierReference.
template: async-function
flags: [noStrict]
---*/
//- setup
var yield = 'prop';
var x = {};
//- elems
[...x[yield]]
//- vals
[33, 44, 55]
//- body
assert.sameValue(x.prop.length, 3);
assert.sameValue(x.prop[0], 33);
assert.sameValue(x.prop[1], 44);
assert.sameValue(x.prop[2], 55);

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.
/*---
path: language/statements/for-await-of/async-func-decl-dstr-
name: for-await-of statement in an async function declaration
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
let iterCount = 0;
async function fn() {
for await (/*{ elems }*/ of [/*{ vals }*/]) {
/*{ body }*/
iterCount += 1;
}
}
let promise = fn();

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.
/*---
path: language/statements/for-await-of/async-gen-decl-dstr-
name: for-await-of statement in an async generator declaration
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
let iterCount = 0;
async function * fn() {
for await (/*{ elems }*/ of [/*{ vals }*/]) {
/*{ body }*/
iterCount += 1;
}
}
let iter = fn();

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.
/*---
path: language/statements/for-await-of/async-func-decl-dstr-
name: for-await-of statement in an async function declaration
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
let iterCount = 0;
async function fn() {
for await (/*{ elems }*/ of [/*{ vals }*/]) {
/*{ body }*/
iterCount += 1;
}
}
let promise = fn();

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.
/*---
path: language/statements/for-await-of/async-gen-decl-dstr-
name: for-await-of statement in an async generator declaration
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
let iterCount = 0;
async function * fn() {
for await (/*{ elems }*/ of [/*{ vals }*/]) {
/*{ body }*/
iterCount += 1;
}
}
let promise = fn().next();

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/for-await-of/dstr-
name: for-await-of statement
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var counter = 0;
async function fn() {
for await (/*{ elems }*/ of [/*{ vals }*/]) {
/*{ body }*/
counter += 1;
}
}
fn()
.then(() => assert.sameValue(counter, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-assignment-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var v2, vNull, vHole, vUndefined, vOob;
var iterCount = 0;
async function fn() {
for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) {
assert.sameValue(v2, 2);
assert.sameValue(vNull, null);
assert.sameValue(vHole, 12);
assert.sameValue(vUndefined, 13);
assert.sameValue(vOob, 14);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,44 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-evaluation-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: The Initializer should only be evaluated if v is undefined. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var flag1 = false, flag2 = false;
var _;
var iterCount = 0;
async function fn() {
for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) {
assert.sameValue(flag1, false);
assert.sameValue(flag2, true);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,54 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var arrow;
var iterCount = 0;
async function fn() {
for await ([ arrow = () => {} ] of [[]]) {
assert.sameValue(arrow.name, 'arrow');
verifyNotEnumerable(arrow, 'name');
verifyNotWritable(arrow, 'name');
verifyConfigurable(arrow, 'name');
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-class-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [class, destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xCls, cls, xCls2;
var iterCount = 0;
async function fn() {
for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) {
assert(xCls.name !== 'xCls');
assert(xCls2.name !== 'xCls2');
assert.sameValue(cls.name, 'cls');
verifyNotEnumerable(cls, 'name');
verifyNotWritable(cls, 'name');
verifyConfigurable(cls, 'name');
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,56 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xCover, cover;
var iterCount = 0;
async function fn() {
for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) {
assert(xCover.name !== 'xCover');
assert.sameValue(cover.name, 'cover');
verifyNotEnumerable(cover, 'name');
verifyNotWritable(cover, 'name');
verifyConfigurable(cover, 'name');
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,56 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-cover-gen.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xCover, cover;
var iterCount = 0;
async function fn() {
for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) {
assert(xCover.name !== 'xCover');
assert.sameValue(cover.name, 'cover');
verifyNotEnumerable(cover, 'name');
verifyNotWritable(cover, 'name');
verifyConfigurable(cover, 'name');
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,56 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [class, destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xFn, fn;
var iterCount = 0;
async function fn() {
for await ([ xFn = function x() {}, fn = function() {} ] of [[]]) {
assert(xFn.name !== 'xFn');
assert.sameValue(fn.name, 'fn');
verifyNotEnumerable(fn, 'name');
verifyNotWritable(fn, 'name');
verifyConfigurable(fn, 'name');
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,40 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-in.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x;
var iterCount = 0;
async function fn() {
for await ([ x = 'x' in {} ] of [[]]) {
assert.sameValue(x, false);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,43 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-order.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Initializer values should be assigned in left-to-right order. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x = 0;
var a, b;
var iterCount = 0;
async function fn() {
for await ([ a = x += 1, b = x *= 2 ] of [[]]) {
assert.sameValue(a, 1);
assert.sameValue(b, 2);
assert.sameValue(x, 2);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,41 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-simple-no-strict.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var argument, eval;
var iterCount = 0;
async function fn() {
for await ([arguments = 4, eval = 5] of [[]]) {
assert.sameValue(arguments, 4);
assert.sameValue(eval, 5);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,36 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-array-yield-ident-valid.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var yield = 'prop';
var x = {};
var iterCount = 0;
async function fn() {
for await ([[x[yield]]] of [[[22]]]) {
assert.sameValue(x.prop, 22);
iterCount += 1;
}
}

View File

@ -0,0 +1,35 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-array.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x;
var iterCount = 0;
async function fn() {
for await ([[x]] of [[[1]]]) {
assert.sameValue(x, 1);
iterCount += 1;
}
}

View File

@ -0,0 +1,42 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-obj-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x;
var iterCount = 0;
async function fn() {
for await ([{ x }] of [[{ x: 2 }]]) {
assert.sameValue(x, 2);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,43 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-ident-valid-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var yield = 2;
var x;
var iterCount = 0;
async function fn() {
for await ([{ x = yield }] of [[{}]]) {
assert.sameValue(x, 2);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,41 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-put-prop-ref-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x = {};
var iterCount = 0;
async function fn() {
for await ([x.y] of [[4]]) {
assert.sameValue(x.y, 4);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,49 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-put-prop-ref-no-get-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x, setValue;
x = {
get y() {
$ERROR('The property should not be accessed.');
},
set y(val) {
setValue = val;
}
};
var iterCount = 0;
async function fn() {
for await ([x.y] of [[23]]) {
assert.sameValue(setValue, 23);
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,38 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict-fn.case
// - src/dstr-assignment-async-iteration/async-function/for-await-of-async-func.template
/*---
description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var iterCount = 0;
async function fn() {
for await ([ unresolvable ] of [[]]) {
iterCount += 1;
}
}
fn()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,44 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-target-simple-no-strict.case
// - src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template
/*---
description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async generator declaration)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var argument, eval;
let iterCount = 0;
async function * fn() {
for await ([arguments, eval] of [[2, 3]]) {
assert.sameValue(arguments, 2);
assert.sameValue(eval, 3);
iterCount += 1;
}
}
let iter = fn();
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,56 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-target-yield-expr.case
// - src/dstr-assignment-async-iteration/async-generator/async-gen-decl.template
/*---
description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [generators, destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var value = [33];
var x = {};
var iterationResult;
let iterCount = 0;
async function * fn() {
for await ([ x[yield] ] of [[33]
]) {
iterCount += 1;
}
}
let iter = fn();
iter.next().then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined);
// TODO add iterCount
//
iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 33);
}).then($DONE, $DONE);
});

View File

@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-assignment-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var v2, vNull, vHole, vUndefined, vOob;
var iterCount = 0;
async function * fn() {
for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) {
assert.sameValue(v2, 2);
assert.sameValue(vNull, null);
assert.sameValue(vHole, 12);
assert.sameValue(vUndefined, 13);
assert.sameValue(vOob, 14);
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,44 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-evaluation-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: The Initializer should only be evaluated if v is undefined. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var flag1 = false, flag2 = false;
var _;
var iterCount = 0;
async function * fn() {
for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) {
assert.sameValue(flag1, false);
assert.sameValue(flag2, true);
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,54 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-arrow-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var arrow;
var iterCount = 0;
async function * fn() {
for await ([ arrow = () => {} ] of [[]]) {
assert.sameValue(arrow.name, 'arrow');
verifyNotEnumerable(arrow, 'name');
verifyNotWritable(arrow, 'name');
verifyConfigurable(arrow, 'name');
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,59 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-class-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [class, destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xCls, cls, xCls2;
var iterCount = 0;
async function * fn() {
for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) {
assert(xCls.name !== 'xCls');
assert(xCls2.name !== 'xCls2');
assert.sameValue(cls.name, 'cls');
verifyNotEnumerable(cls, 'name');
verifyNotWritable(cls, 'name');
verifyConfigurable(cls, 'name');
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,56 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-init-fn-name-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [generators, destructuring-binding, async-iteration]
flags: [generated, async]
includes: [propertyHelper.js]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
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. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
---*/
var xGen, gen;
var iterCount = 0;
async function * fn() {
for await ([ xGen = function* x() {}, gen = function*() {} ] of [[]]) {
assert.notSameValue(xGen.name, 'xGen');
assert.sameValue(gen.name, 'gen');
verifyNotEnumerable(gen, 'name');
verifyNotWritable(gen, 'name');
verifyConfigurable(gen, 'name');
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,64 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-iter-nrml-close-skip.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: IteratorClose is not called when assignment evaluation has exhausted the iterator (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [Symbol.iterator, destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
6. Return result.
---*/
var nextCount = 0;
var returnCount = 0;
var _;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
var iterCount = 0;
async function * fn() {
for await ([ _ ] of [iterable]) {
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,80 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-iter-nrml-close.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: IteratorClose is called when assignment evaluation has not exhausted the iterator (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [Symbol.iterator, destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
---*/
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var _;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
var iterCount = 0;
async function * fn() {
for await ([ _ ] of [iterable]) {
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');
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,42 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-obj-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var x;
var iterCount = 0;
async function * fn() {
for await ([{ x }] of [[{ x: 2 }]]) {
assert.sameValue(x, 2);
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -0,0 +1,53 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-nested-obj-yield-expr.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it behaves as a YieldExpression. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [generators, destructuring-binding, async-iteration]
flags: [generated, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var iter, x;
var iterCount = 0;
async function * fn() {
for await ([{ x = yield }] of [[{}]]) {
iterCount += 1;
}
}
iter = fn();
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,40 @@
// This file was procedurally generated from the following sources:
// - src/dstr-assignment-async-iteration/array-elem-put-unresolvable-no-strict-gen.case
// - src/dstr-assignment-async-iteration/async-generator/for-await-of-async-gen.template
/*---
description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement)
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
features: [destructuring-binding, async-iteration]
flags: [generated, noStrict, async]
info: |
IterationStatement :
for await ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
AssignmentExpression, iterate).
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
5. If destructuring is true and if lhsKind is assignment, then
a. Assert: lhs is a LeftHandSideExpression.
b. Let assignmentPattern be the parse of the source text corresponding to
lhs using AssignmentPattern as the goal symbol.
[...]
---*/
var iterCount = 0;
async function * fn() {
for await ([ unresolvable ] of [[]]) {
assert.sameValue(unresolvable, undefined);
iterCount += 1;
}
}
fn().next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);