Fix evaluation order in non-binding destructuring patterns (#4173)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -281,6 +281,54 @@ function __createIterableObject (arr, methods) {
|
||||
assert (b === 2);
|
||||
}) ();
|
||||
|
||||
(function () {
|
||||
var value = { y: "42" };
|
||||
var x = {};
|
||||
var assignmentResult, iterationResult, iter;
|
||||
|
||||
iter = (function*() {
|
||||
assignmentResult = { y: x[yield] } = value;
|
||||
}());
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert (assignmentResult === undefined);
|
||||
assert (iterationResult.value === undefined);
|
||||
assert (iterationResult.done === false);
|
||||
assert (x.prop === undefined);
|
||||
|
||||
iterationResult = iter.next('prop');
|
||||
|
||||
assert (assignmentResult === value);
|
||||
assert (iterationResult.value === undefined);
|
||||
assert (iterationResult.done === true);
|
||||
assert (x.prop === "42");
|
||||
}) ();
|
||||
|
||||
(function () {
|
||||
var value = { foo: "42" };
|
||||
var x = {};
|
||||
var assignmentResult, iterationResult, iter;
|
||||
|
||||
iter = (function*() {
|
||||
assignmentResult = { ['f' + 'o' + 'o']: x[yield] } = value;
|
||||
}());
|
||||
|
||||
iterationResult = iter.next();
|
||||
|
||||
assert (assignmentResult === undefined);
|
||||
assert (iterationResult.value === undefined);
|
||||
assert (iterationResult.done === false);
|
||||
assert (x.prop === undefined);
|
||||
|
||||
iterationResult = iter.next('prop');
|
||||
|
||||
assert (assignmentResult === value);
|
||||
assert (iterationResult.value === undefined);
|
||||
assert (iterationResult.done === true);
|
||||
assert (x.prop === "42");
|
||||
}) ();
|
||||
|
||||
mustThrow ("var iter = __createIterableObject([], "
|
||||
+ "{ get 'return'() { throw new TypeError() }});"
|
||||
+ "var [a] = iter");
|
||||
|
||||
Reference in New Issue
Block a user