Chromium Code Reviews| Index: tests/compiler/dart2js/js_backend_cps_ir_test.dart |
| diff --git a/tests/compiler/dart2js/js_backend_cps_ir_test.dart b/tests/compiler/dart2js/js_backend_cps_ir_test.dart |
| index df21e239e9825f043c0d19478d6a0a47c1e64cb8..97996efdea0665726a0b9e9ce0182cb4ad57bda0 100644 |
| --- a/tests/compiler/dart2js/js_backend_cps_ir_test.dart |
| +++ b/tests/compiler/dart2js/js_backend_cps_ir_test.dart |
| @@ -3,8 +3,7 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| // VMOptions=-DUSE_CPS_IR=true |
| -// Test that the CPS IR code generator is able to compile the provided |
| -// example programs. |
| +// Test that the CPS IR code generator compiles programs as expected |
|
karlklose
2014/11/20 12:31:18
'expected' -> 'and produces the expected output'?
sigurdm
2014/11/20 13:32:45
Done.
|
| import 'package:async_helper/async_helper.dart'; |
| import 'package:expect/expect.dart'; |
| @@ -14,6 +13,8 @@ import 'memory_compiler.dart'; |
| import 'package:compiler/src/js/js.dart' as js; |
| import 'package:compiler/src/common.dart' show Element; |
| +import 'js_backend_cps_ir_basic.dart' as basic; |
| +import 'js_backend_cps_ir_literals.dart' as literals; |
| const String TEST_MAIN_FILE = 'test.dart'; |
| @@ -23,53 +24,6 @@ class TestEntry { |
| const TestEntry(this.source, [this.expectation]); |
| } |
| -/// The list of tests to run. |
| -const List<TestEntry> tests = const [ |
| - const TestEntry( |
| - """ |
| -foo(a) { |
| - return a; |
| -} |
| -main() { |
| - var a = 10; |
| - var b = 1; |
| - var t; |
| - t = a; |
| - a = b; |
| - b = t; |
| - print(a); |
| - print(b); |
| - print(b); |
| - print(foo(a)); |
| -} |
| - """, |
| - """ |
| -function() { |
| - var a, b; |
| - a = 10; |
| - b = 1; |
| - P.print(b); |
| - P.print(a); |
| - P.print(a); |
| - P.print(V.foo(b)); |
| - return null; |
| -}"""), |
| - const TestEntry( |
| - """ |
| -foo() { return 42; } |
| -main() { return foo(); } |
| - """, |
| - """function() { |
| - return V.foo(); |
| -}"""), |
| - const TestEntry("main() {}"), |
| - const TestEntry("main() { return 42; }"), |
| - const TestEntry("main() { return; }", """ |
| -function() { |
| - return null; |
| -}"""), |
| -]; |
| - |
| String formatTest(Map test) { |
| return test[TEST_MAIN_FILE]; |
| } |
| @@ -83,22 +37,24 @@ String getCodeForMain(Compiler compiler) { |
| main() { |
| Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR")); |
| - for (TestEntry test in tests) { |
| - Map files = {TEST_MAIN_FILE: test.source}; |
| - asyncTest(() { |
| - Compiler compiler = compilerFor(files); |
| - Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); |
| - return compiler.run(uri).then((_) { |
| - Expect.isNotNull(compiler.assembledCode); |
| - String expectation = test.expectation; |
| - if (expectation != null) { |
| - Expect.equals(test.expectation, getCodeForMain(compiler)); |
| - } |
| - }).catchError((e) { |
| - print(e); |
| - Expect.fail('The following test failed to compile:\n' |
| - '${formatTest(files)}'); |
| + for (List<TestEntry> tests in [basic.tests, literals.tests]) { |
|
karlklose
2014/11/20 12:31:18
Could you instead leaves tests where it is as
L
sigurdm
2014/11/20 13:32:45
Done.
|
| + for (TestEntry test in tests) { |
| + Map files = {TEST_MAIN_FILE: test.source}; |
| + asyncTest(() { |
| + Compiler compiler = compilerFor(files); |
| + Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); |
| + return compiler.run(uri).then((_) { |
| + Expect.isNotNull(compiler.assembledCode); |
| + String expectation = test.expectation; |
| + if (expectation != null) { |
| + Expect.equals(test.expectation, getCodeForMain(compiler)); |
| + } |
| + }).catchError((e) { |
| + print(e); |
| + Expect.fail('The following test failed to compile:\n' |
| + '${formatTest(files)}'); |
| + }); |
| }); |
| - }); |
| + } |
| } |
| } |