summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/condswitch.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/ion/condswitch.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/ion/condswitch.js')
-rw-r--r--js/src/jit-test/tests/ion/condswitch.js104
1 files changed, 104 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/condswitch.js b/js/src/jit-test/tests/ion/condswitch.js
new file mode 100644
index 000000000..2ab0a43e4
--- /dev/null
+++ b/js/src/jit-test/tests/ion/condswitch.js
@@ -0,0 +1,104 @@
+// This test case is made to be run with --ion-eager.
+
+function ret2() {
+ return 2;
+}
+
+// Check with default case in the middle.
+function test0(x) {
+ var res = 0;
+ switch (x) {
+ case (res |= 0x40, 1): // x === 1
+ res |= 0x1;
+ default: // otherwise
+ res |= 0x2;
+ case (res |= 0x80, ret2()): // x === 2
+ res |= 0x4;
+ case (res |= 0x100, 1 + ret2()): // x === 3
+ res |= 0x8;
+ break;
+ case (res |= 0x200, 0): // x === 0
+ res |= 0x10;
+ }
+ res |= 0x20;
+ return res;
+}
+
+assertEq(test0(0), 0x40 | 0x80 | 0x100 | 0x200 | 0x10 | 0x20);
+assertEq(test0(1), 0x40 | 0x1 | 0x2 | 0x4 | 0x8 | 0x20);
+assertEq(test0(2), 0x40 | 0x80 | 0x4 | 0x8 | 0x20);
+assertEq(test0(3), 0x40 | 0x80 | 0x100 | 0x8 | 0x20);
+assertEq(test0(4), 0x40 | 0x80 | 0x100 | 0x200 | 0x2 | 0x4 | 0x8 | 0x20);
+
+// Check with no default and only one case.
+function test1(x) {
+ var res = 0;
+ switch (x) {
+ case (res |= 0x1, ret2()): // x === 2
+ res |= 0x2;
+ }
+ res |= 0x4;
+ return res;
+}
+
+assertEq(test1(1), 0x1 | 0x4); // default.
+assertEq(test1(2), 0x1 | 0x2 | 0x4); // case.
+
+// Check with default case identical to a case.
+function test2(x) {
+ var res = 0;
+ switch (x) {
+ case (res |= 0x1, 0):
+ res |= 0x10;
+ break;
+ default:
+ case (res |= 0x2, 1):
+ res |= 0x20;
+ break;
+ case (res |= 0x4, ret2()): // x === 2
+ res |= 0x40;
+ }
+ res |= 0x100;
+ return res;
+}
+
+assertEq(test2(0), 0x1 | 0x10 | 0x100);
+assertEq(test2(1), 0x1 | 0x2 | 0x20 | 0x100);
+assertEq(test2(2), 0x1 | 0x2 | 0x4 | 0x40 | 0x100);
+assertEq(test2(3), 0x1 | 0x2 | 0x4 | 0x20 | 0x100);
+
+// Check a non-break, non-empty default at the end.
+function test3(x) {
+ var res = 0;
+ switch (x) {
+ case (res |= 0x1, 1):
+ res |= 0x10;
+ case (res |= 0x2, ret2()): // x === 2
+ res |= 0x20;
+ default:
+ res |= 0x40;
+ }
+ res |= 0x100;
+ return res;
+}
+
+assertEq(test3(1), 0x1 | 0x10 | 0x20 | 0x40 | 0x100);
+assertEq(test3(2), 0x1 | 0x2 | 0x20 | 0x40 | 0x100);
+assertEq(test3(3), 0x1 | 0x2 | 0x40 | 0x100);
+
+// Check cfg in condition of non-last case with no break. (reverse post order failure ?)
+function test4(x) {
+ var res = 0;
+ switch (x) {
+ case (res |= 0x1, (x ? 1 : 0)):
+ res |= 0x10;
+ case (res |= 0x2, ret2()): // x === 2
+ res |= 0x20;
+ }
+ res |= 0x100;
+ return res;
+}
+
+assertEq(test4(0), 0x1 | 0x10 | 0x20 | 0x100);
+assertEq(test4(1), 0x1 | 0x10 | 0x20 | 0x100);
+assertEq(test4(2), 0x1 | 0x2 | 0x20 | 0x100);