Fix testing for throw in an iterator via yield* throws

IsHTMLDDA is specified in INTERPRETING.md to return null on [[Call]]
when called with no arguments or with single argument "". Return null
causes the iterator protocol to throw.

Also see star-iterable-return-emulates-undefined-throws-when-called.js
This commit is contained in:
Shu-yu Guo 2020-05-04 17:56:01 -07:00 committed by Rick Waldron
parent 1fccea4471
commit f1b0a1e270
1 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,14 @@ var inner = {
var outer = (function* () { yield* inner; })(); var outer = (function* () { yield* inner; })();
outer.next(); outer.next();
outer.throw();
assert.throws(TypeError, function() {
// `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the
// sole argument, and it's specified to return `null` under these conditions.
// As `iter`'s iteration isn't ending because of a throw, the iteration
// protocol will then throw a `TypeError` because `null` isn't an object.
var emptyString = "";
outer.throw(emptyString);
});
assert.sameValue(returnCalls, 0); assert.sameValue(returnCalls, 0);