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

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

Issue 996263002: Don't generate forwarding hooks if all noSuchMethod implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More tests Created 5 years, 9 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: tests/compiler/dart2js/no_such_method_analysis_test.dart
diff --git a/tests/compiler/dart2js/no_such_method_analysis_test.dart b/tests/compiler/dart2js/no_such_method_analysis_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..383bd57f6a4ea361e62c7b4cd9aab80478e07a0e
--- /dev/null
+++ b/tests/compiler/dart2js/no_such_method_analysis_test.dart
@@ -0,0 +1,127 @@
+// Copyright (c) 2015, 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 "package:async_helper/async_helper.dart";
+import 'compiler_helper.dart';
+
+dummyImplTest() {
+ String source = """
+class A {
+ foo() => 3;
+ noSuchMethod(x) => super.noSuchMethod(x);
+}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isFalse(compiler.enabledNoSuchMethod)));
+}
+
+dummyImplTest2() {
+ String source = """
+class A extends B {
+ foo() => 3;
+ noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B {}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isFalse(compiler.enabledNoSuchMethod)));
+}
+
+dummyImplTest3() {
+ String source = """
+class A extends B {
+ foo() => 3;
+ noSuchMethod(x) {
+ return super.noSuchMethod(x);
+ }
+}
+class B {}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isFalse(compiler.enabledNoSuchMethod)));
+}
+
+dummyImplTest4() {
+ String source = """
+class A extends B {
+ foo() => 3;
+ noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B {
+ noSuchMethod(x) => super.noSuchMethod(x);
+}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isFalse(compiler.enabledNoSuchMethod)));
+}
+
+dummyImplTest5() {
+ String source = """
+class A extends B {
+ foo() => 3;
+ noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B {
+ noSuchMethod(x) => throw 'foo';
+}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isTrue(compiler.enabledNoSuchMethod)));
+}
+
+dummyImplTest6() {
+ String source = """
+class A {
+ noSuchMethod(x) => 3;
+}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() =>
+ compiler.runCompiler(uri).then((_) =>
+ Expect.isTrue(compiler.enabledNoSuchMethod)));
+}
+
+main() {
+ dummyImplTest();
+ dummyImplTest2();
+ dummyImplTest3();
+ dummyImplTest4();
+ dummyImplTest5();
+ dummyImplTest6();
+}

Powered by Google App Engine
This is Rietveld 408576698