Skip to content

Commit

Permalink
Merge pull request tc39#651 from bocoup/generation-dstr-assign
Browse files Browse the repository at this point in the history
Re-format destructuring assignment tests
  • Loading branch information
leobalter committed Jun 1, 2016
2 parents 330cea9 + 88879de commit 2cf968c
Show file tree
Hide file tree
Showing 977 changed files with 28,675 additions and 6,115 deletions.
23 changes: 23 additions & 0 deletions src/dstr-assignment/array-elem-init-assignment.case
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);
20 changes: 20 additions & 0 deletions src/dstr-assignment/array-elem-init-evaluation.case
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);
32 changes: 32 additions & 0 deletions src/dstr-assignment/array-elem-init-fn-name-arrow.case
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');
35 changes: 35 additions & 0 deletions src/dstr-assignment/array-elem-init-fn-name-class.case
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');
35 changes: 35 additions & 0 deletions src/dstr-assignment/array-elem-init-fn-name-cover.case
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');
35 changes: 35 additions & 0 deletions src/dstr-assignment/array-elem-init-fn-name-fn.case
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');
35 changes: 35 additions & 0 deletions src/dstr-assignment/array-elem-init-fn-name-gen.case
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');
18 changes: 18 additions & 0 deletions src/dstr-assignment/array-elem-init-in.case
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);
21 changes: 21 additions & 0 deletions src/dstr-assignment/array-elem-init-let.case
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;
21 changes: 21 additions & 0 deletions src/dstr-assignment/array-elem-init-order.case
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);
22 changes: 22 additions & 0 deletions src/dstr-assignment/array-elem-init-simple-no-strict.case
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);
19 changes: 19 additions & 0 deletions src/dstr-assignment/array-elem-init-simple-strict.case
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
[]
35 changes: 35 additions & 0 deletions src/dstr-assignment/array-elem-init-yield-expr.case
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 src/dstr-assignment/array-elem-init-yield-ident-invalid.case
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
[]
Loading

0 comments on commit 2cf968c

Please sign in to comment.