| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 generates source information. | 5 // Test that the CPS IR code generator generates source information. |
| 6 | 6 |
| 7 library source_information_tests; | 7 library source_information_tests; |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; | 61 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; |
| 62 return js.prettyPrint(ast, compiler).getText(); | 62 return js.prettyPrint(ast, compiler).getText(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 runTests(List<TestEntry> tests) { | 65 runTests(List<TestEntry> tests) { |
| 66 for (TestEntry test in tests) { | 66 for (TestEntry test in tests) { |
| 67 Map files = {TEST_MAIN_FILE: test.source}; | 67 Map files = {TEST_MAIN_FILE: test.source}; |
| 68 asyncTest(() { | 68 asyncTest(() { |
| 69 Compiler compiler = compilerFor(files, options: <String>['--use-cps-ir']); | 69 Compiler compiler = compilerFor( |
| 70 memorySourceFiles: files, options: <String>['--use-cps-ir']); |
| 70 ir.FunctionDefinition irNodeForMain; | 71 ir.FunctionDefinition irNodeForMain; |
| 71 | 72 |
| 72 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) { | 73 void cacheIrNodeForMain(Element function, ir.FunctionDefinition irNode) { |
| 73 if (function == compiler.mainFunction) { | 74 if (function == compiler.mainFunction) { |
| 74 assert(irNodeForMain == null); | 75 assert(irNodeForMain == null); |
| 75 irNodeForMain = irNode; | 76 irNodeForMain = irNode; |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 | 79 |
| 79 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); | 80 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 print('Hello'); | 140 print('Hello'); |
| 140 print('World'); | 141 print('World'); |
| 141 } | 142 } |
| 142 """, const ['memory:test.dart:[2,3]', | 143 """, const ['memory:test.dart:[2,3]', |
| 143 'memory:test.dart:[3,3]']), | 144 'memory:test.dart:[3,3]']), |
| 144 ]; | 145 ]; |
| 145 | 146 |
| 146 void main() { | 147 void main() { |
| 147 runTests(tests); | 148 runTests(tests); |
| 148 } | 149 } |
| OLD | NEW |