more tests for "do while" and "while" loops.

This commit is contained in:
Volker 2018-08-02 12:19:20 +02:00
parent f2942bffc5
commit ca673d84ee

View File

@ -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;