OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Dart test for branches. Make sure that shortcuts work, even if they have | |
5 // to jump over several expressions. | |
6 | |
7 import "package:expect/expect.dart"; | |
8 | |
9 class BranchesTest { | |
10 static bool f() { | |
11 Expect.equals("Never reached", 0); | |
12 return true; | |
13 } | |
14 | |
15 static void testMain() { | |
16 int checkPointCounter = 1; | |
17 int checkPoint1 = 0; | |
18 int checkPoint2 = 0; | |
19 int checkPoint3 = 0; | |
20 int checkPoint4 = 0; | |
21 int checkPoint5 = 0; | |
22 int checkPoint6 = 0; | |
23 int i = 0; | |
24 for (int i = 0; i < 2; i++) { | |
25 if (i == 0) { | |
26 checkPoint1 += checkPointCounter++; | |
27 if (true || // Test branch-if-true. | |
28 f() || | |
29 f() || | |
30 f() || | |
31 f() || | |
32 f() || | |
33 f() || | |
34 f() || | |
35 f() || | |
36 f() || | |
37 f() || | |
38 f() || | |
39 f() || | |
40 f() || | |
41 f() || | |
42 f() || | |
43 f() || | |
44 f() || | |
45 f() || | |
46 f() || | |
47 f() || | |
48 f() || | |
49 f() || | |
50 f() || | |
51 f() || | |
52 f() || | |
53 f() || | |
54 f() || | |
55 f() || | |
56 f() || | |
57 f() || | |
58 f() || | |
59 f() || | |
60 f() || | |
61 f() || | |
62 f() || | |
63 f() || | |
64 f() || | |
65 f() || | |
66 f() || | |
67 f() || | |
68 f() || | |
69 f() || | |
70 f() || | |
71 f() || | |
72 f() || | |
73 f() || | |
74 f() || | |
75 f() || | |
76 f() || | |
77 f() || | |
78 f() || | |
79 f() || | |
80 f() || | |
81 f()) { | |
82 checkPoint2 += checkPointCounter++; | |
83 } | |
84 } else { | |
85 // Test branch (jumping over the else branch). | |
86 checkPoint3 += checkPointCounter++; | |
87 if (false) { | |
88 checkPoint4 = checkPointCounter++; // Never reached. | |
89 checkPoint4 = checkPointCounter++; // Never reached. | |
90 checkPoint4 = checkPointCounter++; // Never reached. | |
91 checkPoint4 = checkPointCounter++; // Never reached. | |
92 checkPoint4 = checkPointCounter++; // Never reached. | |
93 checkPoint4 = checkPointCounter++; // Never reached. | |
94 checkPoint4 = checkPointCounter++; // Never reached. | |
95 checkPoint4 = checkPointCounter++; // Never reached. | |
96 checkPoint4 = checkPointCounter++; // Never reached. | |
97 checkPoint4 = checkPointCounter++; // Never reached. | |
98 checkPoint4 = checkPointCounter++; // Never reached. | |
99 checkPoint4 = checkPointCounter++; // Never reached. | |
100 checkPoint4 = checkPointCounter++; // Never reached. | |
101 checkPoint4 = checkPointCounter++; // Never reached. | |
102 checkPoint4 = checkPointCounter++; // Never reached. | |
103 checkPoint4 = checkPointCounter++; // Never reached. | |
104 checkPoint4 = checkPointCounter++; // Never reached. | |
105 checkPoint4 = checkPointCounter++; // Never reached. | |
106 checkPoint4 = checkPointCounter++; // Never reached. | |
107 checkPoint4 = checkPointCounter++; // Never reached. | |
108 checkPoint4 = checkPointCounter++; // Never reached. | |
109 checkPoint4 = checkPointCounter++; // Never reached. | |
110 checkPoint4 = checkPointCounter++; // Never reached. | |
111 checkPoint4 = checkPointCounter++; // Never reached. | |
112 checkPoint4 = checkPointCounter++; // Never reached. | |
113 checkPoint4 = checkPointCounter++; // Never reached. | |
114 checkPoint4 = checkPointCounter++; // Never reached. | |
115 checkPoint4 = checkPointCounter++; // Never reached. | |
116 checkPoint4 = checkPointCounter++; // Never reached. | |
117 checkPoint4 = checkPointCounter++; // Never reached. | |
118 checkPoint4 = checkPointCounter++; // Never reached. | |
119 checkPoint4 = checkPointCounter++; // Never reached. | |
120 checkPoint4 = checkPointCounter++; // Never reached. | |
121 checkPoint4 = checkPointCounter++; // Never reached. | |
122 checkPoint4 = checkPointCounter++; // Never reached. | |
123 checkPoint4 = checkPointCounter++; // Never reached. | |
124 checkPoint4 = checkPointCounter++; // Never reached. | |
125 checkPoint4 = checkPointCounter++; // Never reached. | |
126 checkPoint4 = checkPointCounter++; // Never reached. | |
127 checkPoint4 = checkPointCounter++; // Never reached. | |
128 checkPoint4 = checkPointCounter++; // Never reached. | |
129 checkPoint4 = checkPointCounter++; // Never reached. | |
130 checkPoint4 = checkPointCounter++; // Never reached. | |
131 checkPoint4 = checkPointCounter++; // Never reached. | |
132 checkPoint4 = checkPointCounter++; // Never reached. | |
133 checkPoint4 = checkPointCounter++; // Never reached. | |
134 checkPoint4 = checkPointCounter++; // Never reached. | |
135 checkPoint4 = checkPointCounter++; // Never reached. | |
136 checkPoint4 = checkPointCounter++; // Never reached. | |
137 checkPoint4 = checkPointCounter++; // Never reached. | |
138 checkPoint4 = checkPointCounter++; // Never reached. | |
139 checkPoint4 = checkPointCounter++; // Never reached. | |
140 checkPoint4 = checkPointCounter++; // Never reached. | |
141 checkPoint4 = checkPointCounter++; // Never reached. | |
142 checkPoint4 = checkPointCounter++; // Never reached. | |
143 } | |
144 } | |
145 checkPoint5 += checkPointCounter++; | |
146 } | |
147 checkPoint6 += checkPointCounter++; | |
148 Expect.equals(1, checkPoint1); | |
149 Expect.equals(2, checkPoint2); | |
150 Expect.equals(4, checkPoint3); | |
151 Expect.equals(0, checkPoint4); | |
152 Expect.equals(8, checkPoint5); | |
153 Expect.equals(6, checkPoint6); | |
154 } | |
155 } | |
156 | |
157 main() { | |
158 BranchesTest.testMain(); | |
159 } | |
OLD | NEW |