for-await-of: dstr-assignment, cases

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
Rick Waldron 2017-05-16 16:34:06 -04:00
parent 9f3b85fb21
commit d4fde0a5c3
179 changed files with 3974 additions and 484 deletions

View File

@ -9,7 +9,7 @@ template: default
---*/ ---*/
//- setup //- setup
var v2, vNull, vHole, vUndefined, vOob; let v2, vNull, vHole, vUndefined, vOob;
//- elems //- elems
[v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] [v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14]
//- vals //- vals

View File

@ -8,8 +8,8 @@ template: default
---*/ ---*/
//- setup //- setup
var flag1 = false, flag2 = false; let flag1 = false, flag2 = false;
var _; let _;
//- elems //- elems
[ _ = flag1 = true, _ = flag2 = true ] [ _ = flag1 = true, _ = flag2 = true ]
//- vals //- vals

View File

@ -11,15 +11,13 @@ info: >
7. If Initializer is present and value is undefined and 7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be HasOwnProperty(v, "name"). a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. ReturnIfAbrupt(hasNameProperty). b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js] includes: [propertyHelper.js]
---*/ ---*/
//- setup //- setup
var arrow; let arrow;
//- elems //- elems
[ arrow = () => {} ] [ arrow = () => {} ]
//- vals //- vals

View File

@ -11,16 +11,14 @@ info: >
7. If Initializer is present and value is undefined and 7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be HasOwnProperty(v, "name"). a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. ReturnIfAbrupt(hasNameProperty). b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [class] features: [class]
---*/ ---*/
//- setup //- setup
var xCls, cls, xCls2; let xCls, cls, xCls2;
//- elems //- elems
[ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] [ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -12,15 +12,13 @@ info: >
7. If Initializer is present and value is undefined and 7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be HasOwnProperty(v, "name"). a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. ReturnIfAbrupt(hasNameProperty). b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js] includes: [propertyHelper.js]
---*/ ---*/
//- setup //- setup
var xCover, cover; let xCover, cover;
//- elems //- elems
[ xCover = (0, function() {}), cover = (function() {}) ] [ xCover = (0, function() {}), cover = (function() {}) ]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,27 +11,25 @@ info: >
7. If Initializer is present and value is undefined and 7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be HasOwnProperty(v, "name"). a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. ReturnIfAbrupt(hasNameProperty). b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [class] features: [class]
---*/ ---*/
//- setup //- setup
var xFn, fn; let xFnexp, fnexp;
//- elems //- elems
[ xFn = function x() {}, fn = function() {} ] [ xFnexp = function x() {}, fnexp = function() {} ]
//- vals //- vals
[] []
//- body //- body
assert(xFn.name !== 'xFn'); assert(xFnexp.name !== 'xFnexp');
assert.sameValue(fn.name, 'fn'); assert.sameValue(fnexp.name, 'fnexp');
verifyNotEnumerable(fn, 'name'); verifyNotEnumerable(fnexp, 'name');
verifyNotWritable(fn, 'name'); verifyNotWritable(fnexp, 'name');
verifyConfigurable(fn, 'name'); verifyConfigurable(fnexp, 'name');
//- teardown //- teardown
promise promise

View File

@ -11,16 +11,14 @@ info: >
7. If Initializer is present and value is undefined and 7. If Initializer is present and value is undefined and
IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
DestructuringAssignmentTarget are both true, then DestructuringAssignmentTarget are both true, then
a. Let hasNameProperty be HasOwnProperty(v, "name"). a. Let hasNameProperty be ? HasOwnProperty(v, "name").
b. ReturnIfAbrupt(hasNameProperty). b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
c. If hasNameProperty is false, perform SetFunctionName(v,
GetReferencedName(lref)).
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
//- setup //- setup
var xGen, gen; let xGen, gen;
//- elems //- elems
[ xGen = function* x() {}, gen = function*() {} ] [ xGen = function* x() {}, gen = function*() {} ]
//- vals //- vals

View File

@ -8,7 +8,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[ x = 'x' in {} ] [ x = 'x' in {} ]
//- vals //- vals

View File

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

View File

@ -8,8 +8,8 @@ template: default
---*/ ---*/
//- setup //- setup
var x = 0; let x = 0;
var a, b; let a, b;
//- elems //- elems
[ a = x += 1, b = x *= 2 ] [ a = x += 1, b = x *= 2 ]
//- vals //- vals

View File

@ -11,7 +11,7 @@ flags: [noStrict]
---*/ ---*/
//- setup //- setup
var argument, eval; let argument, eval;
//- elems //- elems
[arguments = 4, eval = 5] [arguments = 4, eval = 5]
//- vals //- vals

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,30 +8,31 @@ info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
[...] [...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result). 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
6. Return result. 5. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: default template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var _; let _;
var iterable = {}; let iterator = {
var iterator = { next() {
next: function() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
}, },
return: function() { return() {
returnCount += 1; returnCount += 1;
return {}; return {};
} }
}; };
iterable[Symbol.iterator] = function() { let iterable = {
return iterator; [Symbol.iterator]() {
return iterator;
}
}; };
//- elems //- elems
[ _ ] [ _ ]
@ -42,6 +43,6 @@ assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);
//- teardown //- teardown
promise iter.next().then(() => {
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) assert.sameValue(iterCount, 1);
.then($DONE, $DONE); }).then($DONE, $DONE);

View File

@ -8,14 +8,13 @@ info: |
ArrayAssignmentPattern : [ AssignmentElementList ] ArrayAssignmentPattern : [ AssignmentElementList ]
[...] [...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
result). 5. Return result.
6. Return result.
7.4.6 IteratorClose( iterator, completion ) 7.4.6 IteratorClose ( iterator, completion )
[...] [...]
6. Let innerResult be Call(return, iterator, « »). 5. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: default template: default
@ -23,20 +22,20 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thisValue = null; let thisValue = null;
var args = null; let args = null;
var _; let _;
var iterable = {}; let iterable = {};
var iterator = { let iterator = {
next: function() { next() {
nextCount += 1; nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant // Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations // implementations
return { done: nextCount > 10 }; return { done: nextCount > 10 };
}, },
return: function() { return() {
returnCount += 1; returnCount += 1;
thisValue = this; thisValue = this;
args = arguments; args = arguments;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,16 +6,20 @@ desc: >
When a `yield` token appears within the DestructuringAssignmentTarget of a When a `yield` token appears within the DestructuringAssignmentTarget of a
nested destructuring assignment outside of strict mode, it behaves as an nested destructuring assignment outside of strict mode, it behaves as an
IdentifierReference. IdentifierReference.
template: default template: async-function
flags: [noStrict] flags: [noStrict]
---*/ ---*/
//- setup //- setup
var yield = 'prop'; let yield = 'prop';
var x = {}; let x = {};
//- elems //- elems
[[x[yield]]] [[x[yield]]]
//- vals //- vals
[[22]] [[22]]
//- body //- body
assert.sameValue(x.prop, 22); assert.sameValue(x.prop, 22);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -6,14 +6,18 @@ desc: >
When DestructuringAssignmentTarget is an array literal, it should be parsed When DestructuringAssignmentTarget is an array literal, it should be parsed
parsed as a DestructuringAssignmentPattern and evaluated as a destructuring parsed as a DestructuringAssignmentPattern and evaluated as a destructuring
assignment. assignment.
template: default template: async-function
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[[x]] [[x]]
//- vals //- vals
[[1]] [[1]]
//- body //- body
assert.sameValue(x, 1); assert.sameValue(x, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ template: async-generator
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
@ -18,14 +18,14 @@ var x;
//- vals //- vals
[{}] [{}]
//- teardown //- teardown
iter.next().then(iterationResult => { iter.next().then(result => {
assert.sameValue(iterationResult.value, undefined); assert.sameValue(result.value, undefined);
assert.sameValue(iterationResult.done, false); assert.sameValue(result.done, false);
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
iter.next(4).then(iterationResult => { iter.next(4).then(result => {
assert.sameValue(iterationResult.value, undefined); assert.sameValue(result.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(result.done, true);
assert.sameValue(x, 4); assert.sameValue(x, 4);
}, $DONE).then($DONE, $DONE); }, $DONE).then($DONE, $DONE);
}, $DONE).catch($DONE); }, $DONE).catch($DONE);

View File

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

View File

@ -11,8 +11,8 @@ flags: [noStrict]
---*/ ---*/
//- setup //- setup
var yield = 2; let yield = 2;
var x; let x;
//- elems //- elems
[{ x = yield }] [{ x = yield }]
//- vals //- vals

View File

@ -10,7 +10,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[{ x }] [{ x }]
//- vals //- vals

View File

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

View File

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

View File

@ -9,7 +9,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x, setValue; let x, setValue;
x = { x = {
get y() { get y() {
$ERROR('The property should not be accessed.'); $ERROR('The property should not be accessed.');

View File

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

View File

@ -9,7 +9,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x = {}; let x = {};
//- elems //- elems
[x.y] [x.y]
//- vals //- vals

View File

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

View File

@ -10,7 +10,7 @@ template: async-function
---*/ ---*/
//- setup //- setup
var x, y, z; let x, y, z;
//- elems //- elems
[x, y, z] [x, y, z]
//- vals //- vals

View File

@ -11,7 +11,7 @@ flags: [noStrict]
---*/ ---*/
//- setup //- setup
var argument, eval; let argument, eval;
//- elems //- elems
[arguments, eval] [arguments, eval]
//- vals //- vals

View File

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

View File

@ -11,9 +11,9 @@ features: [generators]
---*/ ---*/
//- setup //- setup
var value = [33]; let value = [33];
var x = {}; let x = {};
var iterationResult; let iterationResult;
//- elems //- elems
[ x[yield] ] [ x[yield] ]
@ -27,8 +27,6 @@ iter.next().then(iterationResult => {
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined); assert.sameValue(x.prop, undefined);
// TODO add iterCount
//
iter.next('prop').then(iterationResult => { iter.next('prop').then(iterationResult => {
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);

View File

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

View File

@ -11,8 +11,8 @@ flags: [noStrict]
---*/ ---*/
//- setup //- setup
var yield = 'prop'; let yield = 'prop';
var x = {}; let x = {};
//- elems //- elems
[ x[yield] ] [ x[yield] ]
//- vals //- vals

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: IteratorClose not invoked when elision exhausts the iterator desc: IteratorClose not invoked when elision exhausts the iterator
@ -7,13 +7,15 @@ info: |
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...] [...]
6. If Elision is present, then 5. If Elision is present, then
a. Let status be the result of performing a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument. iteratorRecord as the argument.
b. If status is an abrupt completion, then b. If status is an abrupt completion, then
[...]
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, [...]
7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status). status).
9. Return Completion(status). 9. Return Completion(status).
features: [Symbol.iterator] features: [Symbol.iterator]
@ -22,10 +24,10 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var x; let x;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
@ -35,7 +37,7 @@ var iterator = {
returnCount += 1; returnCount += 1;
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: IteratorClose invoked when elision does not exhaust the iterator desc: IteratorClose invoked when elision does not exhaust the iterator
@ -7,19 +7,21 @@ info: |
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...] [...]
6. If Elision is present, then 5. If Elision is present, then
a. Let status be the result of performing a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument. iteratorRecord as the argument.
b. If status is an abrupt completion, then b. If status is an abrupt completion, then
[...]
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
7.4.6 IteratorClose( iterator, completion )
[...] [...]
6. Let innerResult be Call(return, iterator, « »).
7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
@ -27,12 +29,12 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thisValue = null; let thisValue = null;
var args = null; let args = null;
var x; let x;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
@ -47,7 +49,7 @@ var iterator = {
return {}; return {};
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >
@ -9,11 +9,11 @@ info: |
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...] [...]
3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
4. Let status be the result of performing 3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument. iteratorRecord as the argument.
5. If status is an abrupt completion, then 4. If status is an abrupt completion, then
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status). status).
b. Return Completion(status). b. Return Completion(status).
@ -23,13 +23,13 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thrower = function() { let thrower = function() {
throw new Test262Error(); throw new Test262Error();
}; };
var x; let x;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
@ -38,7 +38,7 @@ var iterator = {
returnCount += 1; returnCount += 1;
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >
@ -9,19 +9,19 @@ info: |
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ] [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...] [...]
3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
4. Let status be the result of performing 3. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
iteratorRecord as the argument. iteratorRecord as the argument.
5. If status is an abrupt completion, then 4. If status is an abrupt completion, then
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status). status).
b. Return Completion(status). b. Return Completion(status).
7.4.6 IteratorClose( iterator, completion ) 7.4.6 IteratorClose ( iterator, completion )
[...] [...]
6. Let innerResult be Call(return, iterator, « »). 5. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
@ -29,12 +29,12 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thisValue = null; let thisValue = null;
var args = null; let args = null;
var x; let x;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant // Set an upper-bound to limit unnecessary iteration in non-conformant
@ -48,7 +48,7 @@ var iterator = {
return {}; return {};
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >
@ -6,10 +6,11 @@ desc: >
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
1. Let iterator be GetIterator(value). 1. Let iterator be ? GetIterator(value).
[...] [...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result). 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
@ -17,9 +18,9 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
@ -29,7 +30,7 @@ var iterator = {
return {}; return {};
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >
@ -7,16 +7,17 @@ desc: >
info: | info: |
ArrayAssignmentPattern : [ Elision ] ArrayAssignmentPattern : [ Elision ]
1. Let iterator be GetIterator(value). 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, « »).
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
[...]
7.4.6 IteratorClose ( iterator, completion )
[...]
5. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
@ -24,11 +25,11 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thisValue = null; let thisValue = null;
var args = null; let args = null;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant // Set an upper-bound to limit unnecessary iteration in non-conformant
@ -42,7 +43,7 @@ var iterator = {
return {}; return {};
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: Iterator is closed without iterating desc: Iterator is closed without iterating
@ -9,10 +9,10 @@ info: |
2. ReturnIfAbrupt(iterator). 2. ReturnIfAbrupt(iterator).
3. Return IteratorClose(iterator, NormalCompletion(empty)). 3. Return IteratorClose(iterator, NormalCompletion(empty)).
7.4.6 IteratorClose( iterator, completion ) 7.4.6 IteratorClose ( iterator, completion )
[...] [...]
6. Let innerResult be Call(return, iterator, « »). 5. Let innerResult be Call(return, iterator, « »).
[...] [...]
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
@ -20,11 +20,11 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var thisValue = null; let thisValue = null;
var args = null; let args = null;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
@ -36,7 +36,7 @@ var iterator = {
return {}; return {};
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -10,7 +10,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x, y; let x, y;
//- elems //- elems
[x, ...y] [x, ...y]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -9,7 +9,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[, ...x] [, ...x]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -9,7 +9,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x, y; let x, y;
//- elems //- elems
[, , x, , ...y] [, , x, , ...y]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: > desc: >
@ -8,22 +8,21 @@ info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...] [...]
5. Let result be the result of performing 4. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
iteratorRecord as the argument with iteratorRecord as the argument.
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
result). 6. Return result.
7. Return result.
features: [Symbol.iterator] features: [Symbol.iterator]
template: async-generator template: async-generator
esid: sec-runtime-semantics-destructuringassignmentevaluation esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var x; let x;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
@ -32,7 +31,7 @@ var iterator = {
returnCount += 1; returnCount += 1;
} }
}; };
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }
@ -45,10 +44,7 @@ iterable
assert.sameValue(nextCount, 1); assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0); assert.sameValue(returnCount, 0);
//- teardown
iter.next().then(() => { iter.next()
assert.throws(Test262Error, () => iter.return()); .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
assert.sameValue(returnCount, 1); .then($DONE, $DONE);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
})

View File

@ -1,65 +0,0 @@
// 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

@ -1,66 +0,0 @@
// 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

@ -1,83 +0,0 @@
// 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

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,15 +11,15 @@ features: [generators]
---*/ ---*/
//- setup //- setup
var count = 0; let count = 0;
var g = function*() { let g = function*() {
count += 1; count += 1;
yield; yield;
count += 1; count += 1;
yield; yield;
count += 1; count += 1;
} }
var x; let x;
//- elems //- elems
[...x] [...x]
//- vals //- vals
@ -27,4 +27,9 @@ g()
//- body //- body
assert.sameValue(count, 3); assert.sameValue(count, 3);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
desc: Reference is evaluated during assignment desc: Reference is evaluated during assignment
@ -6,11 +6,11 @@ info: |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
[...] [...]
5. Let result be the result of performing 4. Let result be the result of performing
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
iteratorRecord as the argument with iteratorRecord as the argument.
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
result).
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
@ -25,9 +25,9 @@ esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/ ---*/
//- setup //- setup
var nextCount = 0; let nextCount = 0;
var returnCount = 0; let returnCount = 0;
var iterator = { let iterator = {
next() { next() {
nextCount += 1; nextCount += 1;
return { done: true }; return { done: true };
@ -36,8 +36,8 @@ var iterator = {
returnCount += 1; returnCount += 1;
} }
}; };
var obj = {}; let obj = {};
var iterable = { let iterable = {
[Symbol.iterator]() { [Symbol.iterator]() {
return iterator; return iterator;
} }
@ -52,4 +52,8 @@ assert.sameValue(returnCount, 0);
assert(!!obj.ab); assert(!!obj.ab);
assert.sameValue(obj.ab.length, 0); assert.sameValue(obj.ab.length, 0);
//- teardown
iter.next()
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -10,7 +10,7 @@ template: default
---*/ ---*/
//- setup //- setup
var x, y; let x, y;
//- elems //- elems
[...[x, y]] [...[x, y]]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
//- elems //- elems
[...[x]] [...[x]]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
//- elems //- elems
[...[x]] [...[x]]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
//- elems //- elems
[...[x]] [...[x]]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,8 +11,7 @@ features: [generators]
---*/ ---*/
//- setup //- setup
var value = [86]; let x = {};
var x = {};
//- elems //- elems
[...[x[yield]]] [...[x[yield]]]
@ -24,9 +23,7 @@ iter.next().then(iterationResult => {
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x.prop, undefined); assert.sameValue(x.prop, undefined);
// TODO add iterCount iter.next('prop').then(iterationResult => {
//
iter.next(86).then(iterationResult => {
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);
assert.sameValue(x.prop, 86); assert.sameValue(x.prop, 86);

View File

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

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[...[x]] [...[x]]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x, length; let x, length;
//- elems //- elems
[...{ 0: x, length }] [...{ 0: x, length }]
//- vals //- vals

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers // Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy // where length and name are properties of WindowProxy
let length; let length;
@ -22,3 +22,8 @@ let length;
//- body //- body
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
assert.sameValue(length, 1); assert.sameValue(length, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers // Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy // where length and name are properties of WindowProxy
let length; let length;
@ -22,3 +22,8 @@ let length;
//- body //- body
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
assert.sameValue(length, 1); assert.sameValue(length, 1);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -11,7 +11,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = null; let x = null;
// Use the the top-level lexical scope for 'length' to provide compatibility with browsers // Use the the top-level lexical scope for 'length' to provide compatibility with browsers
// where length and name are properties of WindowProxy // where length and name are properties of WindowProxy
let length; let length;
@ -22,3 +22,8 @@ let length;
//- body //- body
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
assert.sameValue(length, 0); assert.sameValue(length, 0);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -11,7 +11,7 @@ features: [generators]
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[...{ x = yield }] [...{ x = yield }]
@ -23,8 +23,6 @@ iter.next().then(iterationResult => {
assert.sameValue(iterationResult.done, false); assert.sameValue(iterationResult.done, false);
assert.sameValue(x, undefined); assert.sameValue(x, undefined);
// TODO add iterCount
//
iter.next(4).then(iterationResult => { iter.next(4).then(iterationResult => {
assert.sameValue(iterationResult.value, undefined); assert.sameValue(iterationResult.value, undefined);
assert.sameValue(iterationResult.done, true); assert.sameValue(iterationResult.done, true);

View File

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

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -10,10 +10,14 @@ template: default
---*/ ---*/
//- setup //- setup
var x; let x;
//- elems //- elems
[...{ 1: x }] [...{ 1: x }]
//- vals //- vals
[1, 2, 3] [1, 2, 3]
//- body //- body
assert.sameValue(x, 2); assert.sameValue(x, 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -10,8 +10,8 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var setValue; let setValue;
var x = { let x = {
get y() { get y() {
$ERROR('The property should not be accessed.'); $ERROR('The property should not be accessed.');
}, },
@ -28,3 +28,7 @@ assert.sameValue(setValue.length, 3);
assert.sameValue(setValue[0], 23); assert.sameValue(setValue[0], 23);
assert.sameValue(setValue[1], 45); assert.sameValue(setValue[1], 45);
assert.sameValue(setValue[2], 99); assert.sameValue(setValue[2], 99);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
@ -10,7 +10,7 @@ es6id: 12.14.5.3
---*/ ---*/
//- setup //- setup
var x = {}; let x = {};
//- elems //- elems
[...x.y] [...x.y]
//- vals //- vals
@ -20,3 +20,7 @@ assert.sameValue(x.y.length, 3);
assert.sameValue(x.y[0], 4); assert.sameValue(x.y[0], 4);
assert.sameValue(x.y[1], 3); assert.sameValue(x.y[1], 3);
assert.sameValue(x.y[2], 2); assert.sameValue(x.y[2], 2);
//- teardown
promise
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
.then($DONE, $DONE);

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