| 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 // Test that no parts are emitted when deferred loading isn't used. | 5 // Test that no parts are emitted when deferred loading isn't used. |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/dart2jslib.dart'; |
| 7 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 8 import "package:async_helper/async_helper.dart"; | 10 import 'memory_compiler.dart'; |
| 9 import 'memory_source_file_helper.dart'; | |
| 10 | |
| 11 import 'package:compiler/src/dart2jslib.dart' | |
| 12 show NullSink; | |
| 13 | |
| 14 import 'package:compiler/compiler.dart' | |
| 15 show Diagnostic; | |
| 16 | |
| 17 import 'dart:async'; | |
| 18 | 11 |
| 19 main() { | 12 main() { |
| 20 Uri script = currentDirectory.resolveUri(Platform.script); | 13 DiagnosticCollector diagnostics = new DiagnosticCollector(); |
| 21 Uri libraryRoot = script.resolve('../../../sdk/'); | 14 OutputCollector output = new OutputCollector(); |
| 22 Uri packageRoot = script.resolve('./packages/'); | 15 Compiler compiler = compilerFor( |
| 16 MEMORY_SOURCE_FILES, |
| 17 diagnosticHandler: diagnostics, |
| 18 outputProvider: output); |
| 23 | 19 |
| 24 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); | |
| 25 void diagnosticHandler(Uri uri, int begin, int end, | |
| 26 String message, Diagnostic kind) { | |
| 27 if (kind == Diagnostic.VERBOSE_INFO) { | |
| 28 return; | |
| 29 } | |
| 30 throw '$uri:$begin:$end:$message:$kind'; | |
| 31 } | |
| 32 | |
| 33 EventSink<String> outputProvider(String name, String extension) { | |
| 34 if (name != '') throw 'Attempt to output file "$name.$extension"'; | |
| 35 return new NullSink('$name.$extension'); | |
| 36 } | |
| 37 | |
| 38 Compiler compiler = new Compiler(provider.readStringFromUri, | |
| 39 outputProvider, | |
| 40 diagnosticHandler, | |
| 41 libraryRoot, | |
| 42 packageRoot, | |
| 43 [], | |
| 44 {}); | |
| 45 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 20 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 21 Expect.isFalse(diagnostics.hasRegularMessages); |
| 22 Expect.isFalse(output.hasExtraOutput); |
| 46 Expect.isFalse(compiler.compilationFailed); | 23 Expect.isFalse(compiler.compilationFailed); |
| 47 })); | 24 })); |
| 48 } | 25 } |
| 49 | 26 |
| 50 const Map MEMORY_SOURCE_FILES = const { | 27 const Map MEMORY_SOURCE_FILES = const { |
| 51 'main.dart': """ | 28 'main.dart': """ |
| 52 class Greeting { | 29 class Greeting { |
| 53 final message; | 30 final message; |
| 54 const Greeting(this.message); | 31 const Greeting(this.message); |
| 55 } | 32 } |
| 56 | 33 |
| 57 const fisk = const Greeting('Hello, World!'); | 34 const fisk = const Greeting('Hello, World!'); |
| 58 | 35 |
| 59 main() { | 36 main() { |
| 60 var x = fisk; | 37 var x = fisk; |
| 61 if (new DateTime.now().millisecondsSinceEpoch == 42) { | 38 if (new DateTime.now().millisecondsSinceEpoch == 42) { |
| 62 x = new Greeting(\"I\'m confused\"); | 39 x = new Greeting(\"I\'m confused\"); |
| 63 } | 40 } |
| 64 print(x.message); | 41 print(x.message); |
| 65 } | 42 } |
| 66 """, | 43 """, |
| 67 }; | 44 }; |
| OLD | NEW |