diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-02 11:44:42 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-02 11:44:42 -0800 |
commit | 1a9469b0ed84be32dc264effbe7736a03cb7b608 (patch) | |
tree | c47a3e605c5c1d8a8e54ba4c47cad4040c8a313e /test | |
parent | 8d25878a2d49199079b7c81a396ee2d4fb03032d (diff) | |
download | binaryen-1a9469b0ed84be32dc264effbe7736a03cb7b608.tar.gz binaryen-1a9469b0ed84be32dc264effbe7736a03cb7b608.tar.bz2 binaryen-1a9469b0ed84be32dc264effbe7736a03cb7b608.zip |
add do-once and while-forever tests
Diffstat (limited to 'test')
-rw-r--r-- | test/control_flow.cpp | 22 | ||||
-rw-r--r-- | test/control_flow.post.js | 2 | ||||
-rw-r--r-- | test/control_flow.txt | 14 |
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 |