Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// End-to-end test of the analyzer2dart compiler. | 5 /// End-to-end test of the analyzer2dart compiler. |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'mock_sdk.dart'; | 9 import 'mock_sdk.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 if (a) { | 479 if (a) { |
| 480 print(0); | 480 print(0); |
| 481 } else { | 481 } else { |
| 482 print(1); | 482 print(1); |
| 483 print(2); | 483 print(2); |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 '''); | 486 '''); |
| 487 }); | 487 }); |
| 488 | 488 |
| 489 test('If statement', () { | 489 test('Conditional expression', () { |
| 490 checkResult(''' | 490 checkResult(''' |
| 491 main(a) { | 491 main(a) { |
| 492 return a ? print(0) : print(1); | 492 return a ? print(0) : print(1); |
| 493 } | 493 } |
| 494 ''', ''' | 494 ''', ''' |
| 495 main(a) { | 495 main(a) { |
| 496 return a ? print(0) : print(1); | 496 return a ? print(0) : print(1); |
| 497 } | 497 } |
| 498 '''); | 498 '''); |
| 499 }); | 499 }); |
| 500 | |
|
sigurdm
2014/10/21 08:22:44
Maybe it would be beneficial to add a comment to e
Johnni Winther
2014/10/23 06:55:12
Done.
| |
| 501 test('Block statements', () { | |
| 502 checkResult(''' | |
| 503 main(a) { | |
| 504 return 0; | |
| 505 return 1; | |
| 506 } | |
| 507 ''', ''' | |
| 508 main(a) { | |
| 509 return 0; | |
| 510 } | |
| 511 '''); | |
| 512 | |
| 513 checkResult(''' | |
| 514 main(a) { | |
| 515 if (a) { | |
| 516 return 0; | |
| 517 return 1; | |
| 518 } else { | |
| 519 return 2; | |
| 520 return 3; | |
| 521 } | |
| 522 } | |
| 523 ''', ''' | |
| 524 main(a) { | |
| 525 return a ? 0 : 2; | |
| 526 } | |
| 527 '''); | |
| 528 | |
| 529 checkResult(''' | |
| 530 main(a) { | |
| 531 if (a) { | |
| 532 print(0); | |
| 533 return 0; | |
| 534 return 1; | |
| 535 } else { | |
| 536 print(2); | |
| 537 return 2; | |
| 538 return 3; | |
| 539 } | |
| 540 } | |
| 541 ''', ''' | |
| 542 main(a) { | |
| 543 if (a) { | |
| 544 print(0); | |
| 545 return 0; | |
| 546 } else { | |
| 547 print(2); | |
| 548 return 2; | |
| 549 } | |
| 550 } | |
| 551 '''); | |
| 552 }); | |
| 500 } | 553 } |
| 501 | 554 |
| 502 checkResult(String input, [String expectedOutput]) { | 555 checkResult(String input, [String expectedOutput]) { |
| 503 if (expectedOutput == null) { | 556 if (expectedOutput == null) { |
| 504 expectedOutput = input; | 557 expectedOutput = input; |
| 505 } | 558 } |
| 506 | 559 |
| 507 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); | 560 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); |
| 508 MemoryResourceProvider provider = new MemoryResourceProvider(); | 561 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 509 DartSdk sdk = new MockSdk(); | 562 DartSdk sdk = new MockSdk(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 534 sb.write(text); | 587 sb.write(text); |
| 535 } | 588 } |
| 536 | 589 |
| 537 void addError(errorEvent, [StackTrace stackTrace]) {} | 590 void addError(errorEvent, [StackTrace stackTrace]) {} |
| 538 | 591 |
| 539 void close() {} | 592 void close() {} |
| 540 | 593 |
| 541 String get text => sb.toString(); | 594 String get text => sb.toString(); |
| 542 } | 595 } |
| 543 | 596 |
| OLD | NEW |