Skip to content
Snippets Groups Projects
Commit 26676bea authored by jugglinmike's avatar jugglinmike Committed by Leo Balter
Browse files

Add tests for IteratorClose in dstr assignment (#524)

The files in this patch are organized according to the following naming
scheme:

Prefix             | Grammar production
-------------------|-------------------
`array-empty-`     | ArrayAssignmentPattern : [ ]
`array-elision-`   | ArrayAssignmentPattern : [ Elision ]
`array-rest-`      | ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
`array-elem-`      | ArrayAssignmentPattern : [ AssignmentElementList ]
`array-elem-trlg-` | ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]

Suffix             | Intent
-------------------|-------
`-abpt-close-err`  | The assignment evaluation returns an abrupt completion, and the iterator's `return` method throws an error
`-abpt-close-skip` | The assignment evaluation returns an abrupt completion, but IteratorClose is not invoked
`-abpt-close`      | The assignment evaluation returns an abrupt completion, and IteratorClose is invoked as specified
`-get-err`         | Abrupt completion returned from GetIterator
`-nrml-close-err`  | The assignment evaluation completes, and the iterator's `return` method throws an error
`-nrml-close-null` | The assignment evaluation completes, and the iterator's `return` method returns a non-Object value (there is no corresponding `-abpt-` suffix because the algorithm does not reference the return value in those cases)
`-nrml-close-skip` | The assignment evaluation completes, but IteratorClose is not invoked
`-nrml-close`      | The assignment evaluation completes, and IteratorClose is invoked as specified

Not all suffixes are appropriate for all productions. Suffixes have been
simplified in cases where less specificity is necessary to disambiguate
test cases.
parent a657b64a
No related branches found
No related tags found
No related merge requests found
Showing
with 936 additions and 0 deletions
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Abrupt completion returned from GetIterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var iterable = {};
iterable[Symbol.iterator] = function() {
throw new Test262Error();
};
var x;
assert.throws(Test262Error, function() {
[ x ] = iterable;
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Abrupt completion returned from IteratorClose
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var x;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
throw new Test262Error();
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ x ] = iterable;
});
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var x;
var iterable = {};
var nextCount = 0;
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
return null;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(TypeError, function() {
[ x ] = iterable;
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is not called when assignment evaluation has exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, result).
6. Return result.
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var x;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
[ x ] = iterable;
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is called when assignment evaluation has not exhausted the
iterator
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var x;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
[ x ] = iterable;
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is called when reference evaluation produces a "return"
completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var returnCount = 0;
var unreachable = 0;
var iterable = {};
var iterator = {
return: function() {
returnCount += 1;
throw new Test262Error();
}
};
var iter;
iterable[Symbol.iterator] = function() {
return iterator;
};
function* g() {
[ {}[yield] ] = iterable;
unreachable += 1;
}
iter = g();
iter.next();
assert.throws(Test262Error, function() {
iter.return();
});
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
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, generators]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var iterable = {};
var iterator = {
return: function() {
return null;
}
};
var iter;
iterable[Symbol.iterator] = function() {
return iterator;
};
function* g() {
[ {}[yield] ] = iterable;
unreachable += 1;
}
iter = g();
iter.next();
assert.throws(TypeError, function() {
iter.return();
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is called when reference evaluation produces a "return"
completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var returnCount = 0;
var unreachable = 0;
var thisValue = null;
var args = null;
var iterable = {};
var iterator = {
return: function() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
var iter, result;
iterable[Symbol.iterator] = function() {
return iterator;
};
function* g() {
[ {}[yield] ] = iterable;
unreachable += 1;
}
iter = g();
iter.next();
result = iter.return(777);
assert.sameValue(returnCount, 1);
assert.sameValue(unreachable, 0, 'Unreachable statement was not executed');
assert.sameValue(result.value, 777);
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');
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is called when reference evaluation produces a "throw"
completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
function ReturnError() {}
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
// This value should be discarded.
throw new ReturnError();
}
};
var thrower = function() {
throw new Test262Error();
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ {}[thrower()] ] = iterable;
});
assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is not called when iteration produces an abrupt completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
throw new Test262Error();
},
return: function() {
returnCount += 1;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
var x;
assert.throws(Test262Error, function() {
[ x ] = iterable;
});
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is called when reference evaluation produces a "throw"
completion
info: |
ArrayAssignmentPattern : [ AssignmentElementList ]
[...]
5. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
result).
6. Return result.
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
[...]
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var iterable = {};
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
thisValue = this;
args = arguments;
}
};
var thrower = function() {
throw new Test262Error();
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ {}[thrower()] ] = iterable;
});
assert.sameValue(nextCount, 0);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: 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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var x;
var iterator = {
next: function() {
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: function() {
returnCount += 1;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ x , , ] = iterable;
});
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: 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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var x;
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
throw new Test262Error();
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ x , , ] = iterable;
});
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var iterable = {};
var x;
var nextCount = 0;
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
return null;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(TypeError, function() {
[ x , , ] = iterable;
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: IteratorClose not invoked when elision exhausts the iterator
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).
9. Return Completion(status).
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var x;
var iterator = {
next: function() {
nextCount += 1;
return { done: nextCount > 1 };
},
return: function() {
returnCount += 1;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
[ x , , ] = iterable;
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 0);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: IteratorClose invoked when elision does not exhaust the iterator
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, « »).
[...]
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var thisValue = null;
var args = null;
var iterable = {};
var x;
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
thisValue = this;
args = arguments;
return {};
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
[ x , , ] = iterable;
assert.sameValue(nextCount, 2);
assert.sameValue(returnCount, 1);
assert.sameValue(thisValue, iterator, 'correct `this` value');
assert(!!args, 'arguments object provided');
assert.sameValue(args.length, 0, 'zero arguments specified');
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Abrupt completion returned from GetIterator
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
1. Let iterator be GetIterator(value).
2. ReturnIfAbrupt(iterator).
features: [Symbol.iterator]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var iterable = {};
iterable[Symbol.iterator] = function() {
throw new Test262Error();
};
var x;
assert.throws(Test262Error, function() {
[ x , ] = iterable;
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Abrupt completion returned from IteratorClose
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var thrower = function() {
throw new Test262Error();
};
var x;
var iterator = {
next: function() {
nextCount += 1;
return { done: nextCount > 10 };
},
return: function() {
returnCount += 1;
throw new Test262Error();
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(Test262Error, function() {
[ x , ] = iterable;
});
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 1);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose throws a TypeError when `return` returns a non-Object value
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).
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var iterable = {};
var x;
var nextCount = 0;
var iterator = {
next: function() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return: function() {
return null;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
assert.throws(TypeError, function() {
[ x , ] = iterable;
});
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
IteratorClose is not invoked when evaluation of AssignmentElementList
exhausts the iterator
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]
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
var nextCount = 0;
var returnCount = 0;
var iterable = {};
var thrower = function() {
throw new Test262Error();
};
var x;
var iterator = {
next: function() {
nextCount += 1;
return { done: true };
},
return: function() {
returnCount += 1;
}
};
iterable[Symbol.iterator] = function() {
return iterator;
};
[ x , ] = iterable;
assert.sameValue(nextCount, 1);
assert.sameValue(returnCount, 0);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment