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

Unified Diff: tests/language/invocation_mirror_invoke_on2_test.dart

Issue 12207038: Fix issue http://dartbug.com/8350 by dealing with interceptors in invokeOn. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/invocation_mirror_invoke_on2_test.dart
diff --git a/tests/language/invocation_mirror_invoke_on2_test.dart b/tests/language/invocation_mirror_invoke_on2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b8bec8a968478b551ff6407755b5a2db7818654a
--- /dev/null
+++ b/tests/language/invocation_mirror_invoke_on2_test.dart
@@ -0,0 +1,78 @@
+// 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.
+
+class Proxy {
+ final proxied;
+ Proxy(this.proxied);
+ noSuchMethod(mirror) => mirror.invokeOn(proxied);
+}
+
+main() {
+ testList();
+ testString();
+ testInt();
+ testDouble();
ngeoffray 2013/02/06 12:40:39 If you want to be exhaustive, you can also check n
kasperl 2013/02/06 12:46:14 Yeah, but none of those objects have any methods I
ngeoffray 2013/02/06 12:50:31 Good point :)
+}
+
+testList() {
+ var list = [];
+ var proxy = new Proxy(list);
+
+ Expect.isTrue(proxy.isEmpty);
+ Expect.isTrue(list.isEmpty);
+
+ proxy.add(42);
+
+ Expect.isFalse(proxy.isEmpty);
+ Expect.equals(1, proxy.length);
+ Expect.equals(42, proxy[0]);
+
+ Expect.isFalse(list.isEmpty);
+ Expect.equals(1, list.length);
+ Expect.equals(42, list[0]);
+
+ proxy.add(87);
+
+ Expect.equals(2, proxy.length);
+ Expect.equals(87, proxy[1]);
+
+ Expect.equals(2, list.length);
+ Expect.equals(87, list[1]);
+
+ Expect.throws(() => proxy.funky(), (e) => e is NoSuchMethodError);
+ Expect.throws(() => list.funky(), (e) => e is NoSuchMethodError);
+}
+
+testString() {
+ var string = "funky";
+ var proxy = new Proxy(string);
+
+ Expect.equals(string.charCodeAt(0), proxy.charCodeAt(0));
+ Expect.equals(string.length, proxy.length);
+
+ Expect.throws(() => proxy.funky(), (e) => e is NoSuchMethodError);
+ Expect.throws(() => string.funky(), (e) => e is NoSuchMethodError);
+}
+
+testInt() {
+ var number = 42;
+ var proxy = new Proxy(number);
+
+ Expect.equals(number + 87, proxy + 87);
+ Expect.equals(number.toDouble(), proxy.toDouble());
+
+ Expect.throws(() => proxy.funky(), (e) => e is NoSuchMethodError);
+ Expect.throws(() => number.funky(), (e) => e is NoSuchMethodError);
+}
+
+testDouble() {
+ var number = 42.99;
+ var proxy = new Proxy(number);
+
+ Expect.equals(number + 87, proxy + 87);
+ Expect.equals(number.toInt(), proxy.toInt());
+
+ Expect.throws(() => proxy.funky(), (e) => e is NoSuchMethodError);
+ Expect.throws(() => number.funky(), (e) => e is NoSuchMethodError);
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698