OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Dart test program for constructors and initializers. | 4 // Dart test program for constructors and initializers. |
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation | 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 // Check that range analysis does not enter infinite loop trying to propagate | 9 // Check that range analysis does not enter infinite loop trying to propagate |
10 // ranges through dependant phis. | 10 // ranges through dependant phis. |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 foo(n, w) { | 34 foo(n, w) { |
35 var x = 0; | 35 var x = 0; |
36 for (var i = n; i <= w; i++) { | 36 for (var i = n; i <= w; i++) { |
37 Expect.isTrue(i > 0); | 37 Expect.isTrue(i > 0); |
38 x = i; | 38 x = i; |
39 } | 39 } |
40 return x; | 40 return x; |
41 } | 41 } |
42 | 42 |
43 | |
44 // Test detection of unsatisfiable constraints. | 43 // Test detection of unsatisfiable constraints. |
45 f(a, b) { | 44 f(a, b) { |
46 if (a < b) { | 45 if (a < b) { |
47 if (a > b) { | 46 if (a > b) { |
48 throw "unreachable"; | 47 throw "unreachable"; |
49 } | 48 } |
50 return 2; | 49 return 2; |
51 } | 50 } |
52 return 3; | 51 return 3; |
53 } | 52 } |
(...skipping 29 matching lines...) Expand all Loading... |
83 h(n) { | 82 h(n) { |
84 var i; | 83 var i; |
85 for (i = 0; i < n; i++) { | 84 for (i = 0; i < n; i++) { |
86 if (i < 0) throw "unreachable"; | 85 if (i < 0) throw "unreachable"; |
87 var j = i - 1; | 86 var j = i - 1; |
88 if (j >= n - 1) throw "unreachable"; | 87 if (j >= n - 1) throw "unreachable"; |
89 } | 88 } |
90 return i; | 89 return i; |
91 } | 90 } |
92 | 91 |
93 | |
94 test3() { | 92 test3() { |
95 test_fun(fun) { | 93 test_fun(fun) { |
96 Expect.equals(2, fun(0, 1)); | 94 Expect.equals(2, fun(0, 1)); |
97 Expect.equals(3, fun(0, 0)); | 95 Expect.equals(3, fun(0, 0)); |
98 for (var i = 0; i < 20; i++) fun(0, 1); | 96 for (var i = 0; i < 20; i++) fun(0, 1); |
99 Expect.equals(2, fun(0, 1)); | 97 Expect.equals(2, fun(0, 1)); |
100 Expect.equals(3, fun(0, 0)); | 98 Expect.equals(3, fun(0, 0)); |
101 } | 99 } |
102 | 100 |
103 test_fun(f); | 101 test_fun(f); |
104 test_fun(f1); | 102 test_fun(f1); |
105 test_fun(f2); | 103 test_fun(f2); |
106 | 104 |
107 Expect.equals(10, g()); | 105 Expect.equals(10, g()); |
108 for (var i = 0; i < 20; i++) g(); | 106 for (var i = 0; i < 20; i++) g(); |
109 Expect.equals(10, g()); | 107 Expect.equals(10, g()); |
110 | 108 |
111 | |
112 Expect.equals(10, h(10)); | 109 Expect.equals(10, h(10)); |
113 for (var i = 0; i < 20; i++) h(10); | 110 for (var i = 0; i < 20; i++) h(10); |
114 Expect.equals(10, h(10)); | 111 Expect.equals(10, h(10)); |
115 } | 112 } |
116 | 113 |
117 | |
118 main() { | 114 main() { |
119 test1(); | 115 test1(); |
120 test2(); | 116 test2(); |
121 test3(); | 117 test3(); |
122 } | 118 } |
OLD | NEW |