blob: 80070ee6eeb434c0a62530e7457af85938ce3fb9 [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5function Module() {
6 "use asm";
7
8 function if0() {
9 if (0) return 11;
10 return 12;
11 }
12
13 function if1() {
14 if (1) return 13;
15 return 14;
16 }
17
18 function if2() {
19 if (0) return 15;
20 else return 16;
21 }
22
23 function if3() {
24 if (1) return 17;
25 else return 18;
26 }
27
28 function if4() {
29 return 1 ? 19 : 20;
30 }
31
32 function if5() {
33 return 0 ? 21 : 22;
34 }
35
36 function if6() {
37 var x = 0 ? 23 : 24;
38 return x;
39 }
40
41 function if7() {
42 if (0) { var x = 0 ? 25 : 26; }
43 else { var x = 0 ? 27 : 28; }
44 return x;
45 }
46
47 function if8() {
48 if (0) {
49 if (0) { var x = 0 ? 29 : 30; }
50 else { var x = 0 ? 31 : 32; }
51 } else {
52 if (0) { var x = 0 ? 33 : 34; }
53 else { var x = 0 ? 35 : 36; }
54 }
55 return x;
56 }
57
58 return {if0: if0, if1: if1, if2: if2, if3: if3, if4: if4, if5: if5, if6: if6, if7: if7, if8: if8 };
59}
60
61var m = Module();
62assertEquals(12, m.if0());
63assertEquals(13, m.if1());
64assertEquals(16, m.if2());
65assertEquals(17, m.if3());
66assertEquals(19, m.if4());
67assertEquals(22, m.if5());
68assertEquals(24, m.if6());
69assertEquals(28, m.if7());
70assertEquals(36, m.if8());
71
72
73function Spec(a,b,c) {
74 "use asm";
75
76 var xx = a | 0;
77 var yy = b | 0;
78 var zz = c | 0;
79
80 function f() {
81 if (xx) {
82 if (yy) { var x = zz ? 29 : 30; }
83 else { var x = zz ? 31 : 32; }
84 } else {
85 if (yy) { var x = zz ? 33 : 34; }
86 else { var x = zz ? 35 : 36; }
87 }
88 return x;
89 }
90 return {f: f};
91}
92
93assertEquals(36, Spec(0,0,0).f());
94assertEquals(35, Spec(0,0,1).f());
95assertEquals(34, Spec(0,1,0).f());
96assertEquals(33, Spec(0,1,1).f());
97assertEquals(32, Spec(1,0,0).f());
98assertEquals(31, Spec(1,0,1).f());
99assertEquals(30, Spec(1,1,0).f());
100assertEquals(29, Spec(1,1,1).f());