summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/control_flow.cpp22
-rw-r--r--test/control_flow.post.js2
-rw-r--r--test/control_flow.txt14
3 files changed, 38 insertions, 0 deletions
diff --git a/test/control_flow.cpp b/test/control_flow.cpp
index 9536d0504..871e21281 100644
--- a/test/control_flow.cpp
+++ b/test/control_flow.cpp
@@ -43,5 +43,27 @@ int EMSCRIPTEN_KEEPALIVE check_do_loop(int x) {
return x;
}
+int EMSCRIPTEN_KEEPALIVE check_do_once(int x) {
+ do {
+ x *= 2;
+ if (x > 1000) break;
+ x--;
+ if (x > 30) continue;
+ x++;
+ } while (0);
+ return x;
+}
+
+int EMSCRIPTEN_KEEPALIVE check_while_forever(int x) {
+ while (1) {
+ x *= 2;
+ if (x > 1000) break;
+ x--;
+ if (x > 30) continue;
+ x++;
+ }
+ return x;
+}
+
}
diff --git a/test/control_flow.post.js b/test/control_flow.post.js
index 90349b051..839806fe9 100644
--- a/test/control_flow.post.js
+++ b/test/control_flow.post.js
@@ -17,4 +17,6 @@ test('loop');
test('loop_break');
test('loop_continue');
test('do_loop');
+test('do_once');
+test('while_forever');
diff --git a/test/control_flow.txt b/test/control_flow.txt
index e3ef200d9..c541546a6 100644
--- a/test/control_flow.txt
+++ b/test/control_flow.txt
@@ -33,3 +33,17 @@ do_loop
4 ==> 121
11 ==> 169
90 ==> 179
+do_once
+ 1 ==> 2
+ 2 ==> 4
+ 3 ==> 6
+ 4 ==> 8
+ 11 ==> 22
+ 90 ==> 179
+while_forever
+ 1 ==> 1922
+ 2 ==> 1922
+ 3 ==> 1474
+ 4 ==> 1922
+ 11 ==> 1346
+ 90 ==> 1426