OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.invoke_call_through_getter; | 5 library test.invoke_call_through_getter; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 InstanceMirror im = reflect(new C()); | 44 InstanceMirror im = reflect(new C()); |
45 | 45 |
46 Expect.equals('1 5 6', | 46 Expect.equals('1 5 6', |
47 im.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 47 im.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
48 Expect.equals('7, 8', | 48 Expect.equals('7, 8', |
49 im.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 49 im.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
50 Expect.equals('2 C 9 10', | 50 Expect.equals('2 C 9 10', |
51 im.invoke(#closure, [9, 10]).reflectee); | 51 im.invoke(#closure, [9, 10]).reflectee); |
52 Expect.equals('3 C 11 12 13 null', | 52 Expect.equals('3 C 11 12 13 null', |
53 im.invoke(#closureOpt, [11, 12, 13]).reflectee); | 53 im.invoke(#closureOpt, [11, 12, 13]).reflectee); |
54 Expect.equals('4 C 14 15 null 16', // //
/ named: ok | 54 Expect.equals('4 C 14 15 null 16', // //
# named: ok |
55 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //
/ named: continued | 55 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //
# named: continued |
56 Expect.equals('DNU', | 56 Expect.equals('DNU', |
57 im.invoke(#doesNotExist, [17, 18]).reflectee); | 57 im.invoke(#doesNotExist, [17, 18]).reflectee); |
58 Expect.throws(() => im.invoke(#closure, ['wrong arity']), | 58 Expect.throws(() => im.invoke(#closure, ['wrong arity']), |
59 (e) => e is NoSuchMethodError); | 59 (e) => e is NoSuchMethodError); |
60 Expect.throws(() => im.invoke(#notAClosure, []), | 60 Expect.throws(() => im.invoke(#notAClosure, []), |
61 (e) => e is NoSuchMethodError); | 61 (e) => e is NoSuchMethodError); |
62 } | 62 } |
63 | 63 |
64 class D { | 64 class D { |
65 static get fakeFunctionCall => new FakeFunctionCall(); | 65 static get fakeFunctionCall => new FakeFunctionCall(); |
(...skipping 17 matching lines...) Expand all Loading... |
83 ClassMirror cm = reflectClass(D); | 83 ClassMirror cm = reflectClass(D); |
84 | 84 |
85 Expect.equals('1 5 6', | 85 Expect.equals('1 5 6', |
86 cm.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 86 cm.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
87 Expect.equals('7, 8', | 87 Expect.equals('7, 8', |
88 cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 88 cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
89 Expect.equals('2 9 10', | 89 Expect.equals('2 9 10', |
90 cm.invoke(#closure, [9, 10]).reflectee); | 90 cm.invoke(#closure, [9, 10]).reflectee); |
91 Expect.equals('3 11 12 13 null', | 91 Expect.equals('3 11 12 13 null', |
92 cm.invoke(#closureOpt, [11, 12, 13]).reflectee); | 92 cm.invoke(#closureOpt, [11, 12, 13]).reflectee); |
93 Expect.equals('4 14 15 null 16', // ///
named: continued | 93 Expect.equals('4 14 15 null 16', // //#
named: continued |
94 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // ///
named: continued | 94 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //#
named: continued |
95 Expect.throws(() => cm.invoke(#closure, ['wrong arity']), | 95 Expect.throws(() => cm.invoke(#closure, ['wrong arity']), |
96 (e) => e is NoSuchMethodError); | 96 (e) => e is NoSuchMethodError); |
97 } | 97 } |
98 | 98 |
99 get fakeFunctionCall => new FakeFunctionCall(); | 99 get fakeFunctionCall => new FakeFunctionCall(); |
100 get fakeFunctionNSM => new FakeFunctionNSM(); | 100 get fakeFunctionNSM => new FakeFunctionNSM(); |
101 get closure => (x, y) => '2 $x $y'; | 101 get closure => (x, y) => '2 $x $y'; |
102 get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w'; | 102 get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w'; |
103 get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w'; | 103 get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w'; |
104 get notAClosure => 'Not a closure'; | 104 get notAClosure => 'Not a closure'; |
(...skipping 11 matching lines...) Expand all Loading... |
116 LibraryMirror lm = reflectClass(D).owner; | 116 LibraryMirror lm = reflectClass(D).owner; |
117 | 117 |
118 Expect.equals('1 5 6', | 118 Expect.equals('1 5 6', |
119 lm.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 119 lm.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
120 Expect.equals('7, 8', | 120 Expect.equals('7, 8', |
121 lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 121 lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
122 Expect.equals('2 9 10', | 122 Expect.equals('2 9 10', |
123 lm.invoke(#closure, [9, 10]).reflectee); | 123 lm.invoke(#closure, [9, 10]).reflectee); |
124 Expect.equals('3 11 12 13 null', | 124 Expect.equals('3 11 12 13 null', |
125 lm.invoke(#closureOpt, [11, 12, 13]).reflectee); | 125 lm.invoke(#closureOpt, [11, 12, 13]).reflectee); |
126 Expect.equals('4 14 15 null 16', // ///
named: continued | 126 Expect.equals('4 14 15 null 16', // //#
named: continued |
127 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // ///
named: continued | 127 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //#
named: continued |
128 Expect.throws(() => lm.invoke(#closure, ['wrong arity']), | 128 Expect.throws(() => lm.invoke(#closure, ['wrong arity']), |
129 (e) => e is NoSuchMethodError); | 129 (e) => e is NoSuchMethodError); |
130 } | 130 } |
131 | 131 |
132 main() { | 132 main() { |
133 // Access the getters/closures at the base level in this variant. | 133 // Access the getters/closures at the base level in this variant. |
134 testInstanceBase(); | 134 testInstanceBase(); |
135 testInstanceReflective(); | 135 testInstanceReflective(); |
136 testClassBase(); | 136 testClassBase(); |
137 testClassReflective(); | 137 testClassReflective(); |
138 testLibraryBase(); | 138 testLibraryBase(); |
139 testLibraryReflective(); | 139 testLibraryReflective(); |
140 } | 140 } |
OLD | NEW |