| 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 // VMOptions=-DUSE_CPS_IR=true | 4 // VMOptions=-DUSE_CPS_IR=true |
| 5 | 5 |
| 6 // Test that the CPS IR code generator compiles programs and produces the | 6 // Test that the CPS IR code generator compiles programs and produces the |
| 7 // the expected output. | 7 // the expected output. |
| 8 | 8 |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 main() { | 48 main() { |
| 49 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR")); | 49 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR")); |
| 50 | 50 |
| 51 for (TestEntry test in tests) { | 51 for (TestEntry test in tests) { |
| 52 Map files = {TEST_MAIN_FILE: test.source}; | 52 Map files = {TEST_MAIN_FILE: test.source}; |
| 53 asyncTest(() { | 53 asyncTest(() { |
| 54 Compiler compiler = compilerFor(files); | 54 Compiler compiler = compilerFor(files); |
| 55 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); | 55 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); |
| 56 return compiler.run(uri).then((_) { | 56 return compiler.run(uri).then((bool success) { |
| 57 Expect.isNotNull(compiler.assembledCode); | 57 Expect.isTrue(success); |
| 58 String expectation = test.expectation; | 58 String expectation = test.expectation; |
| 59 if (expectation != null) { | 59 if (expectation != null) { |
| 60 String expected = test.expectation; | 60 String expected = test.expectation; |
| 61 String found = getCodeForMain(compiler); | 61 String found = getCodeForMain(compiler); |
| 62 if (expected != found) { | 62 if (expected != found) { |
| 63 Expect.fail('Expected:\n$expected\nbut found\n$found'); | 63 Expect.fail('Expected:\n$expected\nbut found\n$found'); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 }).catchError((e) { | 66 }).catchError((e) { |
| 67 print(e); | 67 print(e); |
| 68 Expect.fail('The following test failed to compile:\n' | 68 Expect.fail('The following test failed to compile:\n' |
| 69 '${formatTest(files)}'); | 69 '${formatTest(files)}'); |
| 70 }); | 70 }); |
| 71 }); | 71 }); |
| 72 } | 72 } |
| 73 } | 73 } |
| OLD | NEW |