Skip to content

Commit d2cba4a

Browse files
ensure that throwing return getter/method only called on success
1 parent c55db1d commit d2cba4a

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

test/built-ins/Iterator/prototype/includes/get-return-method-throws.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ description: >
77
features: [iterator-includes]
88
---*/
99

10+
let counter = 0;
1011
let iterator = {
1112
__proto__: Iterator.prototype,
1213
next() {
13-
return {
14-
done: false,
15-
value: 0,
16-
};
14+
if (counter === 0) {
15+
++counter;
16+
return { done: false, value: 0 };
17+
} else {
18+
return { done: true, value: undefined };
19+
}
1720
},
1821
get return() {
1922
throw new Test262Error();
2023
}
2124
};
2225

26+
assert.sameValue(iterator.includes(1), false);
27+
2328
assert.throws(Test262Error, function() {
2429
iterator.includes(0);
2530
});

test/built-ins/Iterator/prototype/includes/iterator-return-method-throws.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ description: >
77
features: [iterator-includes]
88
---*/
99

10+
let counter = 0;
1011
let iterator = {
1112
__proto__: Iterator.prototype,
1213
next() {
13-
return {
14-
done: false,
15-
value: 0,
16-
};
14+
if (counter === 0) {
15+
++counter;
16+
return { done: false, value: 0 };
17+
} else {
18+
return { done: true, value: undefined };
19+
}
1720
},
1821
return() {
1922
throw new Test262Error();
2023
}
2124
};
2225

26+
assert.sameValue(iterator.includes(1), false);
27+
2328
assert.throws(Test262Error, function() {
2429
iterator.includes(0);
2530
});

0 commit comments

Comments
 (0)