Skip to content

Commit bc803bf

Browse files
committed
Testing an async code in a switch in a loop.
1 parent 528a7ce commit bc803bf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/interop/AsyncInteropTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,28 @@ public void asyncCaseSwitch() {
607607
}
608608
}
609609

610+
@Test
611+
public void testAwaitInSwitchInLoop() {
612+
TestOutput out = new TestOutput();
613+
try (Context context = JSTest.newContextBuilder().out(out).build()) {
614+
context.eval("js", "" //
615+
+ "(async function () {" //
616+
+ " for (o of ['a', 'b']) {" //
617+
+ " switch (o) {" //
618+
+ " case 'a':" //
619+
+ " await 42;" //
620+
+ " console.log('seen a');" //
621+
+ " break;" //
622+
+ " case 'b':" //
623+
+ " console.log('seen b');" //
624+
+ " break;" //
625+
+ " }" //
626+
+ " }" //
627+
+ "})();");
628+
assertEquals("seen a\nseen b\n", out.toString());
629+
}
630+
}
631+
610632
private static Function<String, CompletionStage<String>> asChainable(Value jsFunction) {
611633
assert jsFunction.canExecute();
612634
return v -> {

0 commit comments

Comments
 (0)