| 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 | 4 |
| 5 import 'compiler_helper.dart'; | 5 import 'compiler_helper.dart'; |
| 6 | 6 |
| 7 const int REMOVED = 0; | 7 const int REMOVED = 0; |
| 8 const int ABOVE_ZERO = 1; | 8 const int ABOVE_ZERO = 1; |
| 9 const int BELOW_LENGTH = 2; | 9 const int BELOW_LENGTH = 2; |
| 10 const int KEPT = 3; | 10 const int KEPT = 3; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 for (int i = 0; i < 42; i++) sum += (value & 4); | 191 for (int i = 0; i < 42; i++) sum += (value & 4); |
| 192 var a = new List(); | 192 var a = new List(); |
| 193 if (value >= a.length) return; | 193 if (value >= a.length) return; |
| 194 if (value <= -1) return; | 194 if (value <= -1) return; |
| 195 return a[value]; | 195 return a[value]; |
| 196 } | 196 } |
| 197 """, | 197 """, |
| 198 REMOVED, | 198 REMOVED, |
| 199 ]; | 199 ]; |
| 200 | 200 |
| 201 // TODO(ahe): It would probably be better if this test used the real |
| 202 // core library sources, as its purpose is to detect failure to |
| 203 // optimize fixed-sized arrays. |
| 204 const String DEFAULT_CORELIB_WITH_LIST_INTERFACE = r''' |
| 205 print(var obj) {} |
| 206 abstract class num {} |
| 207 abstract class int extends num { } |
| 208 abstract class double extends num { } |
| 209 class bool {} |
| 210 class String {} |
| 211 class Object {} |
| 212 class Type {} |
| 213 class Function {} |
| 214 interface List default ListImplementation { List([length]);} |
| 215 class ListImplementation { factory List([length]) => null; } |
| 216 abstract class Map {} |
| 217 class Closure {} |
| 218 class Null {} |
| 219 class Dynamic_ {} |
| 220 bool identical(Object a, Object b) {}'''; |
| 221 |
| 201 expect(String code, int kind) { | 222 expect(String code, int kind) { |
| 202 String generated = compile(code); | 223 String generated = |
| 224 compile(code, coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE); |
| 203 switch (kind) { | 225 switch (kind) { |
| 204 case REMOVED: | 226 case REMOVED: |
| 205 Expect.isTrue(!generated.contains('ioore')); | 227 Expect.isTrue(!generated.contains('ioore')); |
| 206 break; | 228 break; |
| 207 | 229 |
| 208 case ABOVE_ZERO: | 230 case ABOVE_ZERO: |
| 209 Expect.isTrue(!generated.contains('< 0')); | 231 Expect.isTrue(!generated.contains('< 0')); |
| 210 Expect.isTrue(generated.contains('ioore')); | 232 Expect.isTrue(generated.contains('ioore')); |
| 211 Expect.isTrue(generated.contains('ioore')); | 233 Expect.isTrue(generated.contains('ioore')); |
| 212 break; | 234 break; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 233 break; | 255 break; |
| 234 } | 256 } |
| 235 } | 257 } |
| 236 | 258 |
| 237 | 259 |
| 238 main() { | 260 main() { |
| 239 for (int i = 0; i < TESTS.length; i += 2) { | 261 for (int i = 0; i < TESTS.length; i += 2) { |
| 240 expect(TESTS[i], TESTS[i + 1]); | 262 expect(TESTS[i], TESTS[i + 1]); |
| 241 } | 263 } |
| 242 } | 264 } |
| OLD | NEW |