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

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

Issue 1020853004: Don't generate invocation mirror code if all noSuchMethods forward to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/no_such_method_enabled_test.dart
diff --git a/tests/compiler/dart2js/no_such_method_enabled_test.dart b/tests/compiler/dart2js/no_such_method_enabled_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a9edd62db28a8bb5231b62f7de441bb1c2b8f546
--- /dev/null
+++ b/tests/compiler/dart2js/no_such_method_enabled_test.dart
@@ -0,0 +1,201 @@
+// 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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
+
+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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
+
+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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
+
+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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ ClassElement clsB = findElement(compiler, 'B');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsB.lookupMember('noSuchMethod')));
+ }));
+}
+
+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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.throwingImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ ClassElement clsB = findElement(compiler, 'B');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.throwingImpls.contains(
+ clsB.lookupMember('noSuchMethod')));
+ }));
+}
+
+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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.otherImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
+
+dummyImplTest7() {
+ String source = """
+class A {
+ noSuchMethod(x, [y]) => 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.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
+
+dummyImplTest8() {
+ String source = """
+class A {
+ noSuchMethod(x, [y]) => super.noSuchMethod(x, y);
+}
+main() {
+ print(new A().foo());
+}
+""";
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(source, uri);
+ asyncTest(() => compiler.runCompiler(uri).then((_) {
+ Expect.isTrue(compiler.backend.enabledNoSuchMethod);
+ ClassElement clsA = findElement(compiler, 'A');
+ Expect.isTrue(
+ compiler.backend.noSuchMethodRegistry.otherImpls.contains(
+ clsA.lookupMember('noSuchMethod')));
+ }));
+}
Johnni Winther 2015/03/20 14:08:55 Add a test for class A { noSuchMethod(x, y) =>
Harry Terkelsen 2015/03/20 18:18:04 Done.
+
+main() {
+ dummyImplTest();
+ dummyImplTest2();
+ dummyImplTest3();
+ dummyImplTest4();
+ dummyImplTest5();
+ dummyImplTest6();
+ dummyImplTest7();
+ dummyImplTest8();
+}
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698