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

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

Issue 11293244: Implement --analyze-all option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Correctly parse metadata Created 8 years, 1 month 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/analyze_all_test.dart
diff --git a/dart/tests/compiler/dart2js/analyze_all_test.dart b/dart/tests/compiler/dart2js/analyze_all_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f172ada1f73850d310ce3ef8b3e21a4816e0b072
--- /dev/null
+++ b/dart/tests/compiler/dart2js/analyze_all_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2012, 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 'dart:uri';
+
+import 'compiler_helper.dart';
+
+import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
+ show MessageKind;
+
+const String SOURCE = """
+class Foo {
+ // Deliberately not const to ensure compile error.
+ Foo(_);
+}
+
+@Bar()
+class Bar {
+ const Bar();
+}
+
+@Foo('x')
+typedef void VoidFunction();
+
+@Foo('y')
+class MyClass {}
+
+main() {
+}
+""";
+
+main() {
+ Uri uri = new Uri('test:code');
+ var compiler = compilerFor(SOURCE, uri, analyzeAll: false);
+ compiler.runCompiler(uri);
+ Expect.isFalse(compiler.compilationFailed);
+ print(compiler.warnings);
+ Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings');
+ Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors');
+ compiler = compilerFor(SOURCE, uri, analyzeAll: true);
+ compiler.runCompiler(uri);
+ Expect.isTrue(compiler.compilationFailed);
+ Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings');
+ Expect.equals(2, compiler.errors.length,
+ 'expected exactly two errors, but got ${compiler.errors}');
+
+ Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST,
+ compiler.errors[0].message.kind);
+ Expect.equals("Foo", compiler.errors[0].node.toString());
+
+ Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST,
+ compiler.errors[1].message.kind);
+ Expect.equals("Foo", compiler.errors[1].node.toString());
+}

Powered by Google App Engine
This is Rietveld 408576698