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

Unified Diff: tests/language/invocation_mirror_test.dart

Issue 11572011: Add more super-invocation InvocationMirror tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test failure to dart2js expectations Created 8 years 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 | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/invocation_mirror_test.dart
diff --git a/tests/language/invocation_mirror_test.dart b/tests/language/invocation_mirror_test.dart
index 765fe08f3ff9c029916a39b9750df56baa7fdc1d..88c5e0a5974bd666c628449e94cfd480224f8945 100644
--- a/tests/language/invocation_mirror_test.dart
+++ b/tests/language/invocation_mirror_test.dart
@@ -11,12 +11,11 @@ class N {
var last;
noSuchMethod(InvocationMirror m) => last = m;
- get wut => this;
-
flif(int x) { Expect.fail("never get here"); }
flaf([int x]) { Expect.fail("never get here"); }
flof({int y}) { Expect.fail("never get here"); }
+ get wut => this;
final int plif = 99;
int get plaf { Expect.fail("never get here"); return 0; }
}
@@ -134,6 +133,13 @@ testInvocationMirrors() {
// Trick call to n.call - wut is a getter returning n again.
testInvocationMirror(n.wut(42), "call", [42], {});
+ // Calling noSuchMethod itself, badly.
+ testInvocationMirror(n.noSuchMethod(), "noSuchMethod", [], {});
+ testInvocationMirror(n.noSuchMethod(37, 42), "noSuchMethod", [37, 42], {});
+ testInvocationMirror(n.noSuchMethod(37, x:42),
+ "noSuchMethod", [37], {"x": 42});
+ testInvocationMirror(n.noSuchMethod(x:42), "noSuchMethod", [], {"x": 42});
+
// Closurizing a method means that calling it badly will not hit the
// original receivers noSuchMethod, only the one inherited from Object
// by the closure object.
@@ -143,6 +149,71 @@ testInvocationMirrors() {
(e) => e is NoSuchMethodError);
}
+class M extends N {
+ noSuchMethod(InvocationMirror m) { throw "never get here"; }
+
+ testSuperCalls() {
+ // Missing property/method access.
+ testInvocationMirror(super.bar, 'bar');
+ testInvocationMirror((){super.bar = 42; return last;}(), 'bar=', [42]);
+ testInvocationMirror(super.bar(), 'bar', [], {});
+ testInvocationMirror(super.bar(42), 'bar', [42], {});
+ testInvocationMirror(super.bar(x: 42), 'bar', [], {"x": 42});
+ testInvocationMirror(super.bar(37, x: 42), 'bar', [37], {"x": 42});
+
+ // Missing operator access.
+ testInvocationMirror(super + 4, '+', [4], {});
+ testInvocationMirror(super - 4, '-', [4], {});
+ testInvocationMirror(-super, 'unary-', [], {});
+ testInvocationMirror(super[42], '[]', [42], {});
+ testInvocationMirror((super[37] = 42).last, '[]=', [37, 42], {});
+
+ // Wrong arguments to existing function.
+ testInvocationMirror(super.flif(), "flif", [], {});
+ testInvocationMirror(super.flif(37, 42), "flif", [37, 42], {});
+ testInvocationMirror(super.flif(x: 42), "flif", [], {"x": 42});
+ testInvocationMirror(super.flif(37, x: 42), "flif", [37], {"x": 42});
+ testInvocationMirror((){super.flif = 42; return last;}(), "flif=", [42]);
+
+ testInvocationMirror(super.flaf(37, 42), "flaf", [37, 42], {});
+ testInvocationMirror(super.flaf(x: 42), "flaf", [], {"x": 42});
+ testInvocationMirror(super.flaf(37, x: 42), "flaf", [37], {"x": 42});
+ testInvocationMirror((){super.flaf = 42; return last;}(), "flaf=", [42]);
+
+ testInvocationMirror(super.flof(37, 42), "flof", [37, 42], {});
+ testInvocationMirror(super.flof(x: 42), "flof", [], {"x": 42});
+ testInvocationMirror(super.flof(37, y: 42), "flof", [37], {"y": 42});
+ testInvocationMirror((){super.flof = 42; return last;}(), "flof=", [42]);
+
+ // Reading works.
+ Expect.isTrue(super.flif is Function);
+ Expect.isTrue(super.flaf is Function);
+ Expect.isTrue(super.flof is Function);
+
+ // Writing to read-only fields.
+ testInvocationMirror((){super.wut = 42; return last;}(), "wut=", [42]);
+ testInvocationMirror((){super.plif = 42; return last;}(), "plif=", [42]);
+ testInvocationMirror((){super.plaf = 42; return last;}(), "plaf=", [42]);
+
+ // Calling noSuchMethod itself, badly.
+ testInvocationMirror(super.noSuchMethod(), "noSuchMethod", [], {});
+ testInvocationMirror(super.noSuchMethod(37, 42),
+ "noSuchMethod", [37, 42], {});
+ testInvocationMirror(super.noSuchMethod(37, x:42),
+ "noSuchMethod", [37], {"x": 42});
+ testInvocationMirror(super.noSuchMethod(x:42),
+ "noSuchMethod", [], {"x": 42});
+
+ // Closurizing a method means that calling it badly will not hit the
+ // original receivers noSuchMethod, only the one inherited from Object
+ // by the closure object.
+ Expect.throws(() { var x = super.flif; x(37, 42); },
+ (e) => e is NoSuchMethodError);
+ }
+}
+
+
+
// Test the NoSuchMethodError thrown by different incorrect calls.
testNoSuchMethodErrors() {
test(Function block) {
@@ -169,4 +240,5 @@ testNoSuchMethodErrors() {
main() {
testInvocationMirrors();
testNoSuchMethodErrors();
+ new M().testSuperCalls();
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698