mirror of
https://github.com/tc39/test262.git
synced 2025-11-13 18:29:44 +01:00
Utilize the test generation tool to increase coverage of destructuring assignment semantics. Previously, only destructuring assignment in the AssignmentExpression position was tested. With this change applied, the same tests will assert expected behavior for destructuring assignment in `for..of` statements, as well. A limited number of tests are applied to the `for..in` statement as well, but due to the iteration protocol observed by that statement, many destructuring tests are not relevant, and others cannot be automatically generated from this format.
40 lines
988 B
Plaintext
40 lines
988 B
Plaintext
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
desc: >
|
|
When a `yield` token appears within the DestructuringAssignmentTarget of
|
|
an AssignmentRestElement and within the body of a generator function, it
|
|
should behave as a YieldExpression.
|
|
template: default
|
|
es6id: 12.14.5
|
|
features: [generators]
|
|
---*/
|
|
|
|
//- setup
|
|
var x = {};
|
|
var iterationResult, iter;
|
|
|
|
iter = (function*() {
|
|
//- elems
|
|
[...x[yield]]
|
|
//- vals
|
|
[33, 44, 55]
|
|
//- teardown
|
|
}());
|
|
|
|
iterationResult = iter.next();
|
|
|
|
assert.sameValue(iterationResult.value, undefined);
|
|
assert.sameValue(iterationResult.done, false);
|
|
assert.sameValue(x.prop, undefined);
|
|
|
|
iterationResult = iter.next('prop');
|
|
|
|
assert.sameValue(iterationResult.value, undefined);
|
|
assert.sameValue(iterationResult.done, true);
|
|
assert.sameValue(x.prop.length, 3);
|
|
assert.sameValue(x.prop[0], 33);
|
|
assert.sameValue(x.prop[1], 44);
|
|
assert.sameValue(x.prop[2], 55);
|