mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
more tests for "do while" and "while" loops.
This commit is contained in:
parent
f2942bffc5
commit
ca673d84ee
@ -47,6 +47,8 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
|||||||
addParam( list, script, "switchDirect" );
|
addParam( list, script, "switchDirect" );
|
||||||
addParam( list, script, "endlessLoop" );
|
addParam( list, script, "endlessLoop" );
|
||||||
addParam( list, script, "doWhileLoop" );
|
addParam( list, script, "doWhileLoop" );
|
||||||
|
addParam( list, script, "doWhileLoopWithBreak" );
|
||||||
|
addParam( list, script, "whileLoop" );
|
||||||
addParam( list, script, "forLoop" );
|
addParam( list, script, "forLoop" );
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -210,6 +212,31 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
|||||||
return d;
|
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
|
@Export
|
||||||
static int forLoop() {
|
static int forLoop() {
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user