| 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 "package:expect/expect.dart"; | 5 import 'dart:async'; |
| 6 import 'package:expect/expect.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; |
| 6 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 7 | 9 |
| 8 const int REMOVED = 0; | 10 const int REMOVED = 0; |
| 9 const int ABOVE_ZERO = 1; | 11 const int ABOVE_ZERO = 1; |
| 10 const int BELOW_LENGTH = 2; | 12 const int BELOW_LENGTH = 2; |
| 11 const int KEPT = 3; | 13 const int KEPT = 3; |
| 12 const int ONE_CHECK = 4; | 14 const int ONE_CHECK = 4; |
| 13 const int ONE_ZERO_CHECK = 5; | 15 const int ONE_ZERO_CHECK = 5; |
| 14 const int BELOW_ZERO_CHECK = 6; | 16 const int BELOW_ZERO_CHECK = 6; |
| 15 | 17 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 340 } |
| 339 class JSFunction { | 341 class JSFunction { |
| 340 } | 342 } |
| 341 class ObjectInterceptor { | 343 class ObjectInterceptor { |
| 342 } | 344 } |
| 343 class JSPositiveInt extends JSInt {} | 345 class JSPositiveInt extends JSInt {} |
| 344 class JSUInt32 extends JSPositiveInt {} | 346 class JSUInt32 extends JSPositiveInt {} |
| 345 class JSUInt31 extends JSUInt32 {} | 347 class JSUInt31 extends JSUInt32 {} |
| 346 getInterceptor(x) {}'''; | 348 getInterceptor(x) {}'''; |
| 347 | 349 |
| 348 expect(String code, int kind) { | 350 Future expect(String code, int kind) { |
| 349 String generated = compile( | 351 return compile( |
| 350 code, | 352 code, |
| 351 coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE, | 353 coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE, |
| 352 interceptorsSource: INTERCEPTORSLIB_WITH_MEMBERS); | 354 interceptorsSource: INTERCEPTORSLIB_WITH_MEMBERS, |
| 353 switch (kind) { | 355 check: (String generated) { |
| 354 case REMOVED: | 356 switch (kind) { |
| 355 Expect.isTrue(!generated.contains('ioore')); | 357 case REMOVED: |
| 356 break; | 358 Expect.isTrue(!generated.contains('ioore')); |
| 359 break; |
| 357 | 360 |
| 358 case ABOVE_ZERO: | 361 case ABOVE_ZERO: |
| 359 Expect.isTrue(!generated.contains('< 0')); | 362 Expect.isTrue(!generated.contains('< 0')); |
| 360 Expect.isTrue(generated.contains('ioore')); | 363 Expect.isTrue(generated.contains('ioore')); |
| 361 break; | 364 break; |
| 362 | 365 |
| 363 case BELOW_ZERO_CHECK: | 366 case BELOW_ZERO_CHECK: |
| 364 Expect.isTrue(generated.contains('< 0')); | 367 Expect.isTrue(generated.contains('< 0')); |
| 365 Expect.isTrue(!generated.contains('||')); | 368 Expect.isTrue(!generated.contains('||')); |
| 366 Expect.isTrue(generated.contains('ioore')); | 369 Expect.isTrue(generated.contains('ioore')); |
| 367 break; | 370 break; |
| 368 | 371 |
| 369 case BELOW_LENGTH: | 372 case BELOW_LENGTH: |
| 370 Expect.isTrue(!generated.contains('||')); | 373 Expect.isTrue(!generated.contains('||')); |
| 371 Expect.isTrue(generated.contains('ioore')); | 374 Expect.isTrue(generated.contains('ioore')); |
| 372 break; | 375 break; |
| 373 | 376 |
| 374 case KEPT: | 377 case KEPT: |
| 375 Expect.isTrue(generated.contains('ioore')); | 378 Expect.isTrue(generated.contains('ioore')); |
| 376 break; | 379 break; |
| 377 | 380 |
| 378 case ONE_CHECK: | 381 case ONE_CHECK: |
| 379 RegExp regexp = new RegExp('ioore'); | 382 RegExp regexp = new RegExp('ioore'); |
| 380 Iterator matches = regexp.allMatches(generated).iterator; | 383 Iterator matches = regexp.allMatches(generated).iterator; |
| 381 checkNumberOfMatches(matches, 1); | 384 checkNumberOfMatches(matches, 1); |
| 382 break; | 385 break; |
| 383 | 386 |
| 384 case ONE_ZERO_CHECK: | 387 case ONE_ZERO_CHECK: |
| 385 RegExp regexp = new RegExp('< 0|>>> 0 !=='); | 388 RegExp regexp = new RegExp('< 0|>>> 0 !=='); |
| 386 Iterator matches = regexp.allMatches(generated).iterator; | 389 Iterator matches = regexp.allMatches(generated).iterator; |
| 387 checkNumberOfMatches(matches, 1); | 390 checkNumberOfMatches(matches, 1); |
| 388 break; | 391 break; |
| 389 } | 392 } |
| 393 }); |
| 390 } | 394 } |
| 391 | 395 |
| 392 | 396 |
| 393 main() { | 397 main() { |
| 394 for (int i = 0; i < TESTS.length; i += 2) { | 398 int i = 0; |
| 395 expect(TESTS[i], TESTS[i + 1]); | 399 Future testNext() { |
| 400 return expect(TESTS[i], TESTS[i + 1]).then((_) { |
| 401 i += 2; |
| 402 if (i < TESTS.length) return testNext(); |
| 403 }); |
| 396 } | 404 } |
| 405 |
| 406 asyncTest(() => testNext()); |
| 397 } | 407 } |
| OLD | NEW |