| Index: dart/tests/compiler/dart2js/unneeded_part_js_test.dart
|
| diff --git a/dart/tests/compiler/dart2js/bad_loop_test.dart b/dart/tests/compiler/dart2js/unneeded_part_js_test.dart
|
| similarity index 60%
|
| copy from dart/tests/compiler/dart2js/bad_loop_test.dart
|
| copy to dart/tests/compiler/dart2js/unneeded_part_js_test.dart
|
| index dbf8795365c83a6b14e41cf5d632c4a0376040e9..aa1e641dbdbeb9dc454641db8bc933bd41a9086a 100644
|
| --- a/dart/tests/compiler/dart2js/bad_loop_test.dart
|
| +++ b/dart/tests/compiler/dart2js/unneeded_part_js_test.dart
|
| @@ -2,12 +2,19 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| +// Test that no parts are emitted when deferred loading isn't used.
|
| +
|
| import 'package:expect/expect.dart';
|
| import 'memory_source_file_helper.dart';
|
|
|
| +import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
|
| + show NullSink;
|
| +
|
| import '../../../sdk/lib/_internal/compiler/compiler.dart'
|
| show Diagnostic;
|
|
|
| +import 'dart:async';
|
| +
|
| main() {
|
| Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script));
|
| Uri libraryRoot = script.resolve('../../../sdk/');
|
| @@ -15,51 +22,44 @@ main() {
|
|
|
| MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
|
| var provider = new MemorySourceFileProvider();
|
| - int warningCount = 0;
|
| - int errorCount = 0;
|
| void diagnosticHandler(Uri uri, int begin, int end,
|
| String message, Diagnostic kind) {
|
| if (kind == Diagnostic.VERBOSE_INFO) {
|
| return;
|
| }
|
| - if (kind == Diagnostic.ERROR) {
|
| - errorCount++;
|
| - } else if (kind == Diagnostic.WARNING) {
|
| - warningCount++;
|
| - } else {
|
| - throw 'unexpected diagnostic $kind: $message';
|
| - }
|
| + throw '$uri:$begin:$end:$message:$kind';
|
| + }
|
| +
|
| + EventSink<String> outputProvider(String name, String extension) {
|
| + if (name != '') throw 'Attempt to output file "$name.$extension"';
|
| + return new NullSink('$name.$extension');
|
| }
|
|
|
| Compiler compiler = new Compiler(provider.readStringFromUri,
|
| - (name, extension) => null,
|
| + outputProvider,
|
| diagnosticHandler,
|
| libraryRoot,
|
| packageRoot,
|
| - ['--analyze-only']);
|
| + []);
|
| compiler.run(Uri.parse('memory:main.dart'));
|
| - Expect.isTrue(compiler.compilationFailed);
|
| - Expect.equals(5, errorCount);
|
| - Expect.equals(1, warningCount);
|
| + Expect.isFalse(compiler.compilationFailed);
|
| }
|
|
|
| const Map MEMORY_SOURCE_FILES = const {
|
| 'main.dart': """
|
| -main() {
|
| - for (var x, y in []) {
|
| - }
|
| -
|
| - for (var x = 10 in []) {
|
| - }
|
| -
|
| - for (x.y in []) { // Also causes a warning "x unresolved".
|
| - }
|
| +class Greeting {
|
| + final message;
|
| + const Greeting(this.message);
|
| +}
|
|
|
| - for ((){}() in []) {
|
| - }
|
| +const fisk = const Greeting('Hello, World!');
|
|
|
| - for (1 in []) {
|
| +main() {
|
| + var x = fisk;
|
| + if (new DateTime.now().millisecondsSinceEpoch == 42) {
|
| + x = new Greeting(\"I\'m confused\");
|
| }
|
| + print(x.message);
|
| }
|
| -"""
|
| +""",
|
| };
|
|
|