diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-02 14:40:44 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-02 14:52:28 -0800 |
commit | 0da73c1845a58823c0fde138115849a65f79e0ea (patch) | |
tree | e50e275ca25442846ea86fe5c5ef25ff7b0ff688 /test/control_flow.cpp | |
parent | 25a335b740da7e7f199edcad617251d19aa6b18b (diff) | |
download | binaryen-0da73c1845a58823c0fde138115849a65f79e0ea.tar.gz binaryen-0da73c1845a58823c0fde138115849a65f79e0ea.tar.bz2 binaryen-0da73c1845a58823c0fde138115849a65f79e0ea.zip |
implement switch
Diffstat (limited to 'test/control_flow.cpp')
-rw-r--r-- | test/control_flow.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/control_flow.cpp b/test/control_flow.cpp index 871e21281..504db2646 100644 --- a/test/control_flow.cpp +++ b/test/control_flow.cpp @@ -65,5 +65,53 @@ int EMSCRIPTEN_KEEPALIVE check_while_forever(int x) { return x; } +int EMSCRIPTEN_KEEPALIVE check_switch(int x) { + switch (x) { + case 1: return 10; + case 3: return 20; + case 5: return 30; + case 10: return 40; + case 11: return 50; + default: return 60; + } + return 70; +} + +int EMSCRIPTEN_KEEPALIVE check_switch_nodefault(int x) { + switch (x) { + case 1: return 10; + case 3: return 20; + case 5: return 30; + case 10: return 40; + case 11: return 50; + } + return 70; +} + +int EMSCRIPTEN_KEEPALIVE check_switch_rdefault(int x) { + switch (x) { + default: return -60; + case 1: return 10; + case 3: return 20; + case 5: return 30; + case 10: return 40; + case 11: return 50; + } + return 70; +} + +int EMSCRIPTEN_KEEPALIVE check_switch_fallthrough(int x) { + switch (x) { + case 1: return 10; + case 2: + case 3: x++; + case 5: return x; + case 10: return 40; + case 11: return 50; + default: return 60; + } + return 70; +} + } |