| 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 is able to compile the provided | 6 // Test that the CPS IR code generator is able to compile the provided |
| 7 // example programs. | 7 // example programs. |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const TestEntry( | 57 const TestEntry( |
| 58 """ | 58 """ |
| 59 foo() { return 42; } | 59 foo() { return 42; } |
| 60 main() { return foo(); } | 60 main() { return foo(); } |
| 61 """, | 61 """, |
| 62 """function() { | 62 """function() { |
| 63 return V.foo(); | 63 return V.foo(); |
| 64 }"""), | 64 }"""), |
| 65 const TestEntry("main() {}"), | 65 const TestEntry("main() {}"), |
| 66 const TestEntry("main() { return 42; }"), | 66 const TestEntry("main() { return 42; }"), |
| 67 const TestEntry("main() { return; }", """ |
| 68 function() { |
| 69 return null; |
| 70 }"""), |
| 67 ]; | 71 ]; |
| 68 | 72 |
| 69 String formatTest(Map test) { | 73 String formatTest(Map test) { |
| 70 return test[TEST_MAIN_FILE]; | 74 return test[TEST_MAIN_FILE]; |
| 71 } | 75 } |
| 72 | 76 |
| 73 String getCodeForMain(Compiler compiler) { | 77 String getCodeForMain(Compiler compiler) { |
| 74 Element mainFunction = compiler.mainFunction; | 78 Element mainFunction = compiler.mainFunction; |
| 75 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; | 79 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; |
| 76 return js.prettyPrint(ast, compiler).getText(); | 80 return js.prettyPrint(ast, compiler).getText(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 Expect.equals(test.expectation, getCodeForMain(compiler)); | 95 Expect.equals(test.expectation, getCodeForMain(compiler)); |
| 92 } | 96 } |
| 93 }).catchError((e) { | 97 }).catchError((e) { |
| 94 print(e); | 98 print(e); |
| 95 Expect.fail('The following test failed to compile:\n' | 99 Expect.fail('The following test failed to compile:\n' |
| 96 '${formatTest(files)}'); | 100 '${formatTest(files)}'); |
| 97 }); | 101 }); |
| 98 }); | 102 }); |
| 99 } | 103 } |
| 100 } | 104 } |
| OLD | NEW |