| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // Test that the CPS IR code generator compiles programs and produces the | 5 // Test that the CPS IR code generator compiles programs and produces the |
| 6 // the expected output. | 6 // the expected output. |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:async_helper/async_helper.dart'; | 10 import 'package:async_helper/async_helper.dart'; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 const String TEST_MAIN_FILE = 'test.dart'; | 112 const String TEST_MAIN_FILE = 'test.dart'; |
| 113 | 113 |
| 114 String _formatTest(Map test) { | 114 String _formatTest(Map test) { |
| 115 return test[TEST_MAIN_FILE]; | 115 return test[TEST_MAIN_FILE]; |
| 116 } | 116 } |
| 117 | 117 |
| 118 String _getCodeForMain(CompilerImpl compiler) { | 118 String _getCodeForMain(CompilerImpl compiler) { |
| 119 Element mainFunction = compiler.mainFunction; | 119 Element mainFunction = compiler.mainFunction; |
| 120 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; | 120 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; |
| 121 return js.prettyPrint(ast, compiler).getText(); | 121 return js.prettyPrint(ast, compiler); |
| 122 } | 122 } |
| 123 | 123 |
| 124 String _getCodeForMethod(CompilerImpl compiler, | 124 String _getCodeForMethod(CompilerImpl compiler, |
| 125 String name) { | 125 String name) { |
| 126 Element foundElement; | 126 Element foundElement; |
| 127 for (Element element in compiler.enqueuer.codegen.generatedCode.keys) { | 127 for (Element element in compiler.enqueuer.codegen.generatedCode.keys) { |
| 128 if (element.toString() == name) { | 128 if (element.toString() == name) { |
| 129 if (foundElement != null) { | 129 if (foundElement != null) { |
| 130 Expect.fail('Multiple compiled elements are called $name'); | 130 Expect.fail('Multiple compiled elements are called $name'); |
| 131 } | 131 } |
| 132 foundElement = element; | 132 foundElement = element; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 if (foundElement == null) { | 136 if (foundElement == null) { |
| 137 Expect.fail('There is no compiled element called $name'); | 137 Expect.fail('There is no compiled element called $name'); |
| 138 } | 138 } |
| 139 | 139 |
| 140 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; | 140 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; |
| 141 return js.prettyPrint(ast, compiler).getText(); | 141 return js.prettyPrint(ast, compiler); |
| 142 } | 142 } |
| OLD | NEW |