Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1814)

Unified Diff: dart/tests/compiler/dart2js/diagnose_ambiguous_test.dart

Issue 14031011: Print the location of duplicated elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix type warnings Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/tests/compiler/dart2js/diagnose_ambiguous_test.dart
diff --git a/dart/tests/compiler/dart2js/diagnose_ambiguous_test.dart b/dart/tests/compiler/dart2js/diagnose_ambiguous_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..08968bf1ff5f2056ed47a731318a5cbd0bfcd2b3
--- /dev/null
+++ b/dart/tests/compiler/dart2js/diagnose_ambiguous_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+import 'package:expect/expect.dart';
+import 'memory_source_file_helper.dart';
+
+import '../../../sdk/lib/_internal/compiler/compiler.dart'
+ show Diagnostic;
+
+import 'dart:json';
+
+main() {
+ Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script));
+ Uri libraryRoot = script.resolve('../../../sdk/');
+ Uri packageRoot = script.resolve('./packages/');
+
+ MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
+ var provider = new MemorySourceFileProvider();
+ var diagnostics = [];
+ void diagnosticHandler(Uri uri, int begin, int end,
+ String message, Diagnostic kind) {
+ if (kind == Diagnostic.VERBOSE_INFO) {
+ return;
+ }
+ diagnostics.add('$uri:$begin:$end:$message:$kind');
+ }
+
+ Compiler compiler = new Compiler(provider.readStringFromUri,
+ (name, extension) => null,
+ diagnosticHandler,
+ libraryRoot,
+ packageRoot,
+ ['--analyze-only']);
+ compiler.run(Uri.parse('memory:main.dart'));
+ diagnostics.sort();
+ var expected = [
+ "memory:exporter.dart:43:47:Info: ""\"function(hest)\" is defined here."
Johnni Winther 2013/06/06 12:28:31 Use ' instead of " to avoid \"
ahe 2013/06/06 13:56:16 Done.
+ ":info",
+ "memory:library.dart:14:19:Info: \"class(Fisk)\" is (re)exported by "
+ "multiple libraries.:info",
+ "memory:library.dart:30:34:Info: \"function(fisk)\" is (re)exported by "
+ "multiple libraries.:info",
+ "memory:library.dart:41:45:Info: \"function(hest)\" is defined here."
+ ":info",
+ "memory:main.dart:0:22:Info: \"class(Fisk)\" is imported here.:info",
+ "memory:main.dart:0:22:Info: \"function(fisk)\" is imported here.:info",
+ "memory:main.dart:0:22:Info: \"function(hest)\" is imported here.:info",
+ "memory:main.dart:23:46:Info: \"class(Fisk)\" is imported here.:info",
+ "memory:main.dart:23:46:Info: \"function(fisk)\" is imported here.:info",
+ "memory:main.dart:23:46:Info: \"function(hest)\" is imported here.:info",
+ "memory:main.dart:59:63:Warning: duplicate import of Fisk:warning",
+ "memory:main.dart:76:80:duplicate import of fisk:error",
+ "memory:main.dart:86:90:duplicate import of hest:error"
+ ];
+ Expect.listEquals(expected, diagnostics);
+ Expect.isTrue(compiler.compilationFailed);
+}
+
+const Map MEMORY_SOURCE_FILES = const {
+ 'main.dart': """
+import 'library.dart';
+import 'exporter.dart';
+
+main() {
+ Fisk x = null;
+ fisk();
+ hest();
+}
+""",
+ 'library.dart': """
+library lib;
+
+class Fisk {
+}
+
+fisk() {}
+
+hest() {}
+""",
+ 'exporter.dart': """
+library exporter;
+
+export 'library.dart';
+
+hest() {}
+""",
+};

Powered by Google App Engine
This is Rietveld 408576698