OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_implicit_getter; | 5 library test.invoke_call_through_implicit_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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 InstanceMirror im = reflect(new C()); | 50 InstanceMirror im = reflect(new C()); |
51 | 51 |
52 Expect.equals('1 5 6', | 52 Expect.equals('1 5 6', |
53 im.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 53 im.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
54 Expect.equals('7, 8', | 54 Expect.equals('7, 8', |
55 im.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 55 im.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
56 Expect.equals('2 C 9 10', | 56 Expect.equals('2 C 9 10', |
57 im.invoke(#closure, [9, 10]).reflectee); | 57 im.invoke(#closure, [9, 10]).reflectee); |
58 Expect.equals('3 C 11 12 13 null', | 58 Expect.equals('3 C 11 12 13 null', |
59 im.invoke(#closureOpt, [11, 12, 13]).reflectee); | 59 im.invoke(#closureOpt, [11, 12, 13]).reflectee); |
60 Expect.equals('4 C 14 15 null 16', | 60 Expect.equals('4 C 14 15 null 16', ///
named: ok |
61 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); | 61 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); ///
named: continued |
62 Expect.equals('DNU', | 62 Expect.equals('DNU', |
63 im.invoke(#doesNotExist, [17, 18]).reflectee); | 63 im.invoke(#doesNotExist, [17, 18]).reflectee); |
64 Expect.throws(() => im.invoke(#closure, ['wrong arity']), | 64 Expect.throws(() => im.invoke(#closure, ['wrong arity']), /// getter_call_stu
b: ok |
65 (e) => e is NoSuchMethodError); | 65 (e) => e is NoSuchMethodError); /// getter_call_stu
b: continued |
66 Expect.throws(() => im.invoke(#notAClosure, []), | 66 Expect.throws(() => im.invoke(#notAClosure, []), /// getter_call_stu
b: continued |
67 (e) => e is NoSuchMethodError); | 67 (e) => e is NoSuchMethodError); /// getter_call_stu
b: continued |
68 } | 68 } |
69 | 69 |
70 class D { | 70 class D { |
71 static var fakeFunctionCall = new FakeFunctionCall(); | 71 static var fakeFunctionCall = new FakeFunctionCall(); |
72 static var fakeFunctionNSM = new FakeFunctionNSM(); | 72 static var fakeFunctionNSM = new FakeFunctionNSM(); |
73 static var closure = (x, y) => '2 $x $y'; | 73 static var closure = (x, y) => '2 $x $y'; |
74 static var closureOpt = (x, y, [z, w]) => '3 $x $y $z $w'; | 74 static var closureOpt = (x, y, [z, w]) => '3 $x $y $z $w'; |
75 static var closureNamed = (x, y, {z, w}) => '4 $x $y $z $w'; | 75 static var closureNamed = (x, y, {z, w}) => '4 $x $y $z $w'; |
76 static var notAClosure = 'Not a closure'; | 76 static var notAClosure = 'Not a closure'; |
77 } | 77 } |
(...skipping 11 matching lines...) Expand all Loading... |
89 ClassMirror cm = reflectClass(D); | 89 ClassMirror cm = reflectClass(D); |
90 | 90 |
91 Expect.equals('1 5 6', | 91 Expect.equals('1 5 6', |
92 cm.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 92 cm.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
93 Expect.equals('7, 8', | 93 Expect.equals('7, 8', |
94 cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 94 cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
95 Expect.equals('2 9 10', | 95 Expect.equals('2 9 10', |
96 cm.invoke(#closure, [9, 10]).reflectee); | 96 cm.invoke(#closure, [9, 10]).reflectee); |
97 Expect.equals('3 11 12 13 null', | 97 Expect.equals('3 11 12 13 null', |
98 cm.invoke(#closureOpt, [11, 12, 13]).reflectee); | 98 cm.invoke(#closureOpt, [11, 12, 13]).reflectee); |
99 Expect.equals('4 14 15 null 16', | 99 Expect.equals('4 14 15 null 16', /// n
amed: continued |
100 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); | 100 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); /// n
amed: continued |
101 Expect.throws(() => cm.invoke(#closure, ['wrong arity']), | 101 Expect.throws(() => cm.invoke(#closure, ['wrong arity']), |
102 (e) => e is NoSuchMethodError); | 102 (e) => e is NoSuchMethodError); |
103 } | 103 } |
104 | 104 |
105 var fakeFunctionCall = new FakeFunctionCall(); | 105 var fakeFunctionCall = new FakeFunctionCall(); |
106 var fakeFunctionNSM = new FakeFunctionNSM(); | 106 var fakeFunctionNSM = new FakeFunctionNSM(); |
107 var closure = (x, y) => '2 $x $y'; | 107 var closure = (x, y) => '2 $x $y'; |
108 var closureOpt = (x, y, [z, w]) => '3 $x $y $z $w'; | 108 var closureOpt = (x, y, [z, w]) => '3 $x $y $z $w'; |
109 var closureNamed = (x, y, {z, w}) => '4 $x $y $z $w'; | 109 var closureNamed = (x, y, {z, w}) => '4 $x $y $z $w'; |
110 var notAClosure = 'Not a closure'; | 110 var notAClosure = 'Not a closure'; |
(...skipping 11 matching lines...) Expand all Loading... |
122 LibraryMirror lm = reflectClass(D).owner; | 122 LibraryMirror lm = reflectClass(D).owner; |
123 | 123 |
124 Expect.equals('1 5 6', | 124 Expect.equals('1 5 6', |
125 lm.invoke(#fakeFunctionCall, [5, 6]).reflectee); | 125 lm.invoke(#fakeFunctionCall, [5, 6]).reflectee); |
126 Expect.equals('7, 8', | 126 Expect.equals('7, 8', |
127 lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); | 127 lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); |
128 Expect.equals('2 9 10', | 128 Expect.equals('2 9 10', |
129 lm.invoke(#closure, [9, 10]).reflectee); | 129 lm.invoke(#closure, [9, 10]).reflectee); |
130 Expect.equals('3 11 12 13 null', | 130 Expect.equals('3 11 12 13 null', |
131 lm.invoke(#closureOpt, [11, 12, 13]).reflectee); | 131 lm.invoke(#closureOpt, [11, 12, 13]).reflectee); |
132 Expect.equals('4 14 15 null 16', | 132 Expect.equals('4 14 15 null 16', /// na
med: continued |
133 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); | 133 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); /// na
med: continued |
134 Expect.throws(() => lm.invoke(#closure, ['wrong arity']), | 134 Expect.throws(() => lm.invoke(#closure, ['wrong arity']), |
135 (e) => e is NoSuchMethodError); | 135 (e) => e is NoSuchMethodError); |
136 } | 136 } |
137 | 137 |
138 main() { | 138 main() { |
139 testInstanceBase(); | 139 testInstanceBase(); |
140 testInstanceReflective(); | 140 testInstanceReflective(); |
141 testClassBase(); | 141 testClassBase(); |
142 testClassReflective(); | 142 testClassReflective(); |
143 testLibraryBase(); | 143 testLibraryBase(); |
144 testLibraryReflective(); | 144 testLibraryReflective(); |
145 } | 145 } |
OLD | NEW |