forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tc39#651 from bocoup/generation-dstr-assign
Re-format destructuring assignment tests
- Loading branch information
Showing
977 changed files
with
28,675 additions
and
6,115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2015 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
If the Initializer is present and v is undefined, the Initializer should be | ||
evaluated and the result assigned to the target reference. | ||
template: default | ||
es6id: 12.14.5.3 | ||
---*/ | ||
|
||
//- setup | ||
var v2, vNull, vHole, vUndefined, vOob; | ||
//- elems | ||
[v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] | ||
//- vals | ||
[2, null, , undefined] | ||
//- body | ||
assert.sameValue(v2, 2); | ||
assert.sameValue(vNull, null); | ||
assert.sameValue(vHole, 12); | ||
assert.sameValue(vUndefined, 13); | ||
assert.sameValue(vOob, 14); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2015 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
The Initializer should only be evaluated if v is undefined. | ||
template: default | ||
es6id: 12.14.5.3 | ||
---*/ | ||
|
||
//- setup | ||
var flag1 = false, flag2 = false; | ||
var _; | ||
//- elems | ||
[ _ = flag1 = true, _ = flag2 = true ] | ||
//- vals | ||
[14] | ||
//- body | ||
assert.sameValue(flag1, false); | ||
assert.sameValue(flag2, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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 (ArrowFunction) | ||
template: default | ||
es6id: 12.14.5.3 | ||
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 (ClassExpression) | ||
template: default | ||
es6id: 12.14.5.3 | ||
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; | ||
//- elems | ||
[ xCls = class x {},cls = class {} ] | ||
//- vals | ||
[] | ||
//- body | ||
assert(xCls.name !== 'xCls'); | ||
|
||
assert.sameValue(cls.name, 'cls'); | ||
verifyNotEnumerable(cls, 'name'); | ||
verifyNotWritable(cls, 'name'); | ||
verifyConfigurable(cls, 'name'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 | ||
es6id: 12.14.5.3 | ||
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 | ||
es6id: 12.14.5.3 | ||
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 (GeneratorExpression) | ||
template: default | ||
es6id: 12.14.5.3 | ||
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
The Initializer in an AssignmentElement may be an `in` expression. | ||
template: default | ||
es6id: 12.14.5 | ||
---*/ | ||
|
||
//- setup | ||
var x; | ||
//- elems | ||
[ x = 'x' in {} ] | ||
//- vals | ||
[] | ||
//- body | ||
assert.sameValue(x, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
Value retrieval of Initializer obeys `let` semantics. | ||
template: error | ||
es6id: 12.14.5.3 | ||
features: [let] | ||
---*/ | ||
|
||
//- error | ||
ReferenceError | ||
//- setup | ||
var x; | ||
//- elems | ||
[ x = y ] | ||
//- vals | ||
[] | ||
//- teardown | ||
let y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
Initializer values should be assigned in left-to-right order. | ||
template: default | ||
es6id: 12.14.5.3 | ||
---*/ | ||
|
||
//- 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
Identifiers that appear as the DestructuringAssignmentTarget in an | ||
AssignmentElement should take on the iterated value corresponding to their | ||
position in the ArrayAssignmentPattern. | ||
template: default | ||
es6id: 12.14.5.3 | ||
flags: [noStrict] | ||
---*/ | ||
|
||
//- setup | ||
var argument, eval; | ||
//- elems | ||
[arguments = 4, eval = 5] | ||
//- vals | ||
[] | ||
//- body | ||
assert.sameValue(arguments, 4); | ||
assert.sameValue(eval, 5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
It is a Syntax Error if LeftHandSideExpression is neither an | ||
ObjectLiteral nor an ArrayLiteral and | ||
IsValidSimpleAssignmentTarget(LeftHandSideExpression) is | ||
false. | ||
template: syntax | ||
es6id: 12.14.5.1 | ||
flags: [onlyStrict] | ||
negative: SyntaxError | ||
---*/ | ||
|
||
//- elems | ||
[arguments] | ||
//- values | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 an | ||
AssignmentElement within a generator function body, it behaves as a | ||
YieldExpression. | ||
template: default | ||
es6id: 12.14.5.4 | ||
features: [generators] | ||
---*/ | ||
|
||
//- setup | ||
var value = []; | ||
var iterationResult, iter, x; | ||
iter = (function*() { | ||
//- elems | ||
[ x = yield ] | ||
//- vals | ||
[] | ||
//- teardown | ||
})(); | ||
|
||
iterationResult = iter.next(); | ||
|
||
assert.sameValue(iterationResult.value, undefined); | ||
assert.sameValue(iterationResult.done, false); | ||
assert.sameValue(x, undefined); | ||
|
||
iterationResult = iter.next(86); | ||
|
||
assert.sameValue(iterationResult.value, undefined); | ||
assert.sameValue(iterationResult.done, true); | ||
assert.sameValue(x, 86); |
17 changes: 17 additions & 0 deletions
17
src/dstr-assignment/array-elem-init-yield-ident-invalid.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: > | ||
When a `yield` token appears within the Initializer of an AssignmentElement | ||
outside of a generator function body, it behaves as an IdentifierReference. | ||
template: syntax | ||
es6id: 12.14.5.4 | ||
flags: [onlyStrict] | ||
negative: SyntaxError | ||
---*/ | ||
|
||
//- elems | ||
[ x = yield ] | ||
//- vals | ||
[] |
Oops, something went wrong.