From ca673d84ee661fa7b4c3187b5c1a35d2d67f3c76 Mon Sep 17 00:00:00 2001 From: Volker Date: Thu, 2 Aug 2018 12:19:20 +0200 Subject: [PATCH] more tests for "do while" and "while" loops. --- .../runtime/ControlFlowOperators.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java b/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java index 4a80601..9334682 100644 --- a/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java +++ b/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java @@ -47,6 +47,8 @@ public class ControlFlowOperators extends AbstractBaseTest { addParam( list, script, "switchDirect" ); addParam( list, script, "endlessLoop" ); addParam( list, script, "doWhileLoop" ); + addParam( list, script, "doWhileLoopWithBreak" ); + addParam( list, script, "whileLoop" ); addParam( list, script, "forLoop" ); } return list; @@ -210,6 +212,31 @@ public class ControlFlowOperators extends AbstractBaseTest { return d; } + @Export + static double doWhileLoopWithBreak() { + int a = 0; + double d = 1.01; + do { + a++; + if( a == 5 ) { + break; + } + d *= 2; + } while( a < 10 ); + return a * d; + } + + @Export + static int whileLoop() { + float a = 0; + int b = 1; + while( a < 10 ) { + b *= 2; + a++; + } + return b; + } + @Export static int forLoop() { int a = 0;