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

Unified Diff: test/codegen/lib/mirrors/delegate_call_through_getter_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 | « test/codegen/lib/mirrors/deferred_type_test.dart ('k') | test/codegen/lib/mirrors/delegate_class_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/mirrors/delegate_call_through_getter_test.dart
diff --git a/test/codegen/lib/mirrors/delegate_call_through_getter_test.dart b/test/codegen/lib/mirrors/delegate_call_through_getter_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4d0d088ad7b44b7071efc7f14779d1a273757963
--- /dev/null
+++ b/test/codegen/lib/mirrors/delegate_call_through_getter_test.dart
@@ -0,0 +1,45 @@
+// 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.
+
+library test.invoke_call_through_getter;
+
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+class FakeFunctionCall {
+ call(x, y) => '1 $x $y';
+}
+class FakeFunctionNSM {
+ noSuchMethod(msg) => msg.positionalArguments.join(', ');
+}
+
+class C {
+ get fakeFunctionCall => new FakeFunctionCall();
+ get fakeFunctionNSM => new FakeFunctionNSM();
+ get closure => (x, y) => '2 $this $x $y';
+ get closureOpt => (x, y, [z, w]) => '3 $this $x $y $z $w';
+ get closureNamed => (x, y, {z, w}) => '4 $this $x $y $z $w';
+ get notAClosure => 'Not a closure';
+ noSuchMethod(msg) => 'DNU';
+
+ toString() => 'C';
+}
+
+class Forwarder {
+ noSuchMethod(msg) => reflect(new C()).delegate(msg);
+}
+
+main() {
+ var f = new Forwarder();
+
+ Expect.equals('1 5 6', f.fakeFunctionCall(5, 6));
+ Expect.equals('7, 8', f.fakeFunctionNSM(7, 8));
+ Expect.equals('2 C 9 10', f.closure(9, 10));
+ Expect.equals('3 C 11 12 13 null', f.closureOpt(11, 12, 13));
+ Expect.equals('4 C 14 15 null 16', f.closureNamed(14, 15, w: 16));
+ Expect.equals('DNU', f.doesNotExist(17, 18));
+ Expect.throws(() => f.closure('wrong arity'), (e) => e is NoSuchMethodError);
+ Expect.throws(() => f.notAClosure(), (e) => e is NoSuchMethodError);
+}
« no previous file with comments | « test/codegen/lib/mirrors/deferred_type_test.dart ('k') | test/codegen/lib/mirrors/delegate_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698