File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/interop
com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/control Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff 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\n seen b\n " , out .toString ());
629+ }
630+ }
631+
610632 private static Function <String , CompletionStage <String >> asChainable (Value jsFunction ) {
611633 assert jsFunction .canExecute ();
612634 return v -> {
Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ public Object resume(VirtualFrame frame) {
207207 int statementIndex ;
208208 Object resumptionResult ;
209209 if (maybeState instanceof SwitchResumptionRecord ) {
210+ resetState (frame );
210211 SwitchResumptionRecord state = (SwitchResumptionRecord ) maybeState ;
211212 caseIndex = state .caseIndex ;
212213 statementIndex = state .statementIndex ;
You can’t perform that action at this time.
0 commit comments