| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.test.uri_retention_test; | 5 library dart2js.test.uri_retention_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 11 | 11 |
| 12 import 'memory_compiler.dart' show | 12 import 'memory_compiler.dart' show |
| 13 compilerFor, OutputCollector; | 13 compilerFor; |
| 14 | 14 |
| 15 Future<String> compileSources(sources, {bool minify, bool preserveUri}) { | 15 Future<String> compileSources(sources, {bool minify, bool preserveUri}) { |
| 16 var options = []; | 16 var options = []; |
| 17 if (minify) options.add("--minify"); | 17 if (minify) options.add("--minify"); |
| 18 if (preserveUri) options.add("--preserve-uris"); | 18 if (preserveUri) options.add("--preserve-uris"); |
| 19 OutputCollector outputCollector = new OutputCollector(); | 19 var compiler = compilerFor(sources, options: options); |
| 20 var compiler = compilerFor( | |
| 21 sources, options: options, outputProvider: outputCollector); | |
| 22 return compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) { | 20 return compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) { |
| 23 return outputCollector.getOutput('', 'js'); | 21 return compiler.assembledCode; |
| 24 }); | 22 }); |
| 25 } | 23 } |
| 26 | 24 |
| 27 Future test(sources, { bool libName, bool fileName }) { | 25 Future test(sources, { bool libName, bool fileName }) { |
| 28 return | 26 return |
| 29 compileSources(sources, minify: false, preserveUri: false).then((output) { | 27 compileSources(sources, minify: false, preserveUri: false).then((output) { |
| 30 // Unminified the sources should always contain the library name and the | 28 // Unminified the sources should always contain the library name and the |
| 31 // file name. | 29 // file name. |
| 32 Expect.isTrue(output.contains("main_lib")); | 30 Expect.isTrue(output.contains("main_lib")); |
| 33 Expect.isTrue(output.contains("main.dart")); | 31 Expect.isTrue(output.contains("main.dart")); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 library main_lib; | 102 library main_lib; |
| 105 | 103 |
| 106 @MirrorsUsed(targets: 'main_lib') | 104 @MirrorsUsed(targets: 'main_lib') |
| 107 import 'dart:mirrors'; | 105 import 'dart:mirrors'; |
| 108 | 106 |
| 109 main() { | 107 main() { |
| 110 print(currentMirrorSystem().findLibrary(#main_lib).uri); | 108 print(currentMirrorSystem().findLibrary(#main_lib).uri); |
| 111 } | 109 } |
| 112 """, | 110 """, |
| 113 }; | 111 }; |
| OLD | NEW |