Skip to content

Commit

Permalink
Use separate function for loop body when testing cancellation behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Jan 26, 2019
1 parent 2d01b91 commit 3468631
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions streams/readable-streams/async-iterator.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ promise_test(async () => {
}
});

await (async () => {
// use a separate function for the loop body so return does not stop the test
const loop = async () => {
for await (const c of s.getIterator({ preventCancel })) {
if (type === 'throw') {
throw new Error();
Expand All @@ -92,7 +93,11 @@ promise_test(async () => {
return;
}
}
})().catch(() => 0);
};

try {
await loop();
} catch (e) {}

if (preventCancel) {
assert_array_equals(s.events, ['pull'], `cancel() should not be called when type = '${type}' and preventCancel is true`);
Expand Down

0 comments on commit 3468631

Please sign in to comment.