OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Invocation and noSuchMethod testing. | 7 // Invocation and noSuchMethod testing. |
8 | 8 |
| 9 Map<Symbol, dynamic> listToNamedArguments(list) { |
| 10 var iterator = list.iterator; |
| 11 var result = new Map<Symbol, dynamic>(); |
| 12 while (iterator.moveNext()) { |
| 13 Symbol key = iterator.current; |
| 14 Expect.isTrue(iterator.moveNext()); |
| 15 result[key] = iterator.current; |
| 16 } |
| 17 return result; |
| 18 } |
| 19 |
| 20 |
9 /** Class with noSuchMethod that returns the mirror */ | 21 /** Class with noSuchMethod that returns the mirror */ |
10 class N { | 22 class N { |
11 // Storage for the last argument to noSuchMethod. | 23 // Storage for the last argument to noSuchMethod. |
12 // Needed for setters, which don't evaluate to the return value. | 24 // Needed for setters, which don't evaluate to the return value. |
13 var last; | 25 var last; |
14 noSuchMethod(Invocation m) => last = m; | 26 noSuchMethod(Invocation m) => last = m; |
15 | 27 |
16 flif(int x) { Expect.fail("never get here"); } | 28 flif(int x) { Expect.fail("never get here"); } |
17 flaf([int x]) { Expect.fail("never get here"); } | 29 flaf([int x]) { Expect.fail("never get here"); } |
18 flof({int y}) { Expect.fail("never get here"); } | 30 flof({int y}) { Expect.fail("never get here"); } |
19 | 31 |
20 get wut => this; | 32 get wut => this; |
21 final int plif = 99; | 33 final int plif = 99; |
22 int get plaf { Expect.fail("never get here"); return 0; } | 34 int get plaf { Expect.fail("never get here"); return 0; } |
23 } | 35 } |
24 | 36 |
25 /** As [N] but also implements 'call', so we can call it with wrong arguments.*/ | 37 /** As [N] but also implements 'call', so we can call it with wrong arguments.*/ |
26 class C extends N { | 38 class C extends N { |
27 call(int x) { Expect.fail("never get here"); } | 39 call(int x) { Expect.fail("never get here"); } |
28 } | 40 } |
29 | 41 |
30 /** | 42 /** |
31 * Checks the data of an Invocation. | 43 * Checks the data of an Invocation. |
32 * | 44 * |
33 * Call without optionals for getters, with only positional for setters, | 45 * Call without optionals for getters, with only positional for setters, |
34 * and with both optionals for everything else. | 46 * and with both optionals for everything else. |
35 */ | 47 */ |
36 testInvocationMirror(Invocation im, String name, | 48 testInvocationMirror(Invocation im, Symbol name, |
37 [List positional, Map named]) { | 49 [List positional, List named]) { |
38 Expect.isTrue(im is Invocation, "is Invocation"); | 50 Expect.isTrue(im is Invocation, "is Invocation"); |
39 Expect.equals(name, im.memberName, "name"); | 51 Expect.equals(name, im.memberName, "name"); |
40 if (named == null) { | 52 if (named == null) { |
41 Expect.isTrue(im.isAccessor, "$name:isAccessor"); | 53 Expect.isTrue(im.isAccessor, "$name:isAccessor"); |
42 Expect.isFalse(im.isMethod, "$name:isMethod"); | 54 Expect.isFalse(im.isMethod, "$name:isMethod"); |
43 if (positional == null) { | 55 if (positional == null) { |
44 Expect.isTrue(im.isGetter, "$name:isGetter"); | 56 Expect.isTrue(im.isGetter, "$name:isGetter"); |
45 Expect.isFalse(im.isSetter, "$name:isSetter"); | 57 Expect.isFalse(im.isSetter, "$name:isSetter"); |
46 Expect.equals(0, im.positionalArguments.length, "$name:#positional"); | 58 Expect.equals(0, im.positionalArguments.length, "$name:#positional"); |
47 Expect.equals(0, im.namedArguments.length, "$name:#named"); | 59 Expect.equals(0, im.namedArguments.length, "$name:#named"); |
48 return; | 60 return; |
49 } | 61 } |
50 Expect.isTrue(im.isSetter, "$name:isSetter"); | 62 Expect.isTrue(im.isSetter, "$name:isSetter"); |
51 Expect.isFalse(im.isGetter, "$name:isGetter"); | 63 Expect.isFalse(im.isGetter, "$name:isGetter"); |
52 Expect.equals(1, im.positionalArguments.length, "$name:#positional"); | 64 Expect.equals(1, im.positionalArguments.length, "$name:#positional"); |
53 Expect.equals(positional[0], im.positionalArguments[0], | 65 Expect.equals(positional[0], im.positionalArguments[0], |
54 "$name:positional[0]"); | 66 "$name:positional[0]"); |
55 Expect.equals(0, im.namedArguments.length, "$name:#named"); | 67 Expect.equals(0, im.namedArguments.length, "$name:#named"); |
56 return; | 68 return; |
57 } | 69 } |
| 70 Map<Symbol, dynamic> namedArguments = listToNamedArguments(named); |
58 Expect.isTrue(im.isMethod, "$name:isMethod"); | 71 Expect.isTrue(im.isMethod, "$name:isMethod"); |
59 Expect.isFalse(im.isAccessor, "$name:isAccessor"); | 72 Expect.isFalse(im.isAccessor, "$name:isAccessor"); |
60 Expect.isFalse(im.isSetter, "$name:isSetter"); | 73 Expect.isFalse(im.isSetter, "$name:isSetter"); |
61 Expect.isFalse(im.isGetter, "$name:isGetter"); | 74 Expect.isFalse(im.isGetter, "$name:isGetter"); |
62 | 75 |
63 Expect.equals(positional.length, im.positionalArguments.length); | 76 Expect.equals(positional.length, im.positionalArguments.length); |
64 for (int i = 0; i < positional.length; i++) { | 77 for (int i = 0; i < positional.length; i++) { |
65 Expect.equals(positional[i], im.positionalArguments[i], | 78 Expect.equals(positional[i], im.positionalArguments[i], |
66 "$name:positional[$i]"); | 79 "$name:positional[$i]"); |
67 } | 80 } |
68 Expect.equals(named.length, im.namedArguments.length, "$name:#named"); | 81 Expect.equals(namedArguments.length, im.namedArguments.length, |
69 named.forEach((k, v) { | 82 "$name:#named"); |
70 Expect.isTrue(im.namedArguments.containsKey(k), "$name:?named[$k]"); | 83 namedArguments.forEach((k, v) { |
71 Expect.equals(v, im.namedArguments[k], "$name:named[$k]"); | 84 Expect.isTrue(im.namedArguments.containsKey(k), |
| 85 "$name:?namedArguments[$k]"); |
| 86 Expect.equals(v, im.namedArguments[k], "$name:namedArguments[$k]"); |
72 }); | 87 }); |
73 } | 88 } |
74 | 89 |
75 | 90 |
76 // Test different ways that noSuchMethod can be called. | 91 // Test different ways that noSuchMethod can be called. |
77 testInvocationMirrors() { | 92 testInvocationMirrors() { |
78 var n = new N(); | 93 var n = new N(); |
79 var c = new C(); | 94 var c = new C(); |
80 | 95 |
81 // Missing property/method access. | 96 // Missing property/method access. |
82 testInvocationMirror(n.bar, 'bar'); | 97 testInvocationMirror(n.bar, const Symbol('bar')); |
83 testInvocationMirror((n..bar = 42).last, 'bar=', [42]); | 98 testInvocationMirror((n..bar = 42).last, const Symbol('bar='), [42]); |
84 testInvocationMirror(n.bar(), 'bar', [], {}); | 99 testInvocationMirror(n.bar(), const Symbol('bar'), [], []); |
85 testInvocationMirror(n.bar(42), 'bar', [42], {}); | 100 testInvocationMirror(n.bar(42), const Symbol('bar'), [42], []); |
86 testInvocationMirror(n.bar(x: 42), 'bar', [], {"x": 42}); | 101 testInvocationMirror(n.bar(x: 42), const Symbol('bar'), [], |
87 testInvocationMirror(n.bar(37, x: 42), 'bar', [37], {"x": 42}); | 102 [const Symbol("x"), 42]); |
| 103 testInvocationMirror(n.bar(37, x: 42), const Symbol('bar'), [37], |
| 104 [const Symbol("x"), 42]); |
88 | 105 |
89 // Missing operator access. | 106 // Missing operator access. |
90 testInvocationMirror(n + 4, '+', [4], {}); | 107 testInvocationMirror(n + 4, const Symbol('+'), [4], []); |
91 testInvocationMirror(n - 4, '-', [4], {}); | 108 testInvocationMirror(n - 4, const Symbol('-'), [4], []); |
92 testInvocationMirror(-n, 'unary-', [], {}); | 109 testInvocationMirror(-n, const Symbol('unary-'), [], []); |
93 testInvocationMirror(n[42], '[]', [42], {}); | 110 testInvocationMirror(n[42], const Symbol('[]'), [42], []); |
94 testInvocationMirror((n..[37] = 42).last, '[]=', [37, 42], {}); | 111 testInvocationMirror((n..[37] = 42).last, const Symbol('[]='), [37, 42], []); |
95 | 112 |
96 // Calling as function when it's not. | 113 // Calling as function when it's not. |
97 testInvocationMirror(n(), 'call', [], {}); | 114 testInvocationMirror(n(), const Symbol('call'), [], []); |
98 testInvocationMirror(n(42), 'call', [42], {}); | 115 testInvocationMirror(n(42), const Symbol('call'), [42], []); |
99 testInvocationMirror(n(x: 42), 'call', [], {"x": 42}); | 116 testInvocationMirror(n(x: 42), const Symbol('call'), [], |
100 testInvocationMirror(n(37, x: 42), 'call', [37], {"x": 42}); | 117 [const Symbol("x"), 42]); |
| 118 testInvocationMirror(n(37, x: 42), const Symbol('call'), [37], |
| 119 [const Symbol("x"), 42]); |
101 | 120 |
102 // Calling with arguments not matching existing call method. | 121 // Calling with arguments not matching existing call method. |
103 testInvocationMirror(c(), 'call', [], {}); | 122 testInvocationMirror(c(), const Symbol('call'), [], []); |
104 testInvocationMirror(c(37, 42), 'call', [37, 42], {}); | 123 testInvocationMirror(c(37, 42), const Symbol('call'), [37, 42], []); |
105 testInvocationMirror(c(x: 42), 'call', [], {"x": 42}); | 124 testInvocationMirror(c(x: 42), const Symbol('call'), [], |
106 testInvocationMirror(c(37, x: 42), 'call', [37], {"x": 42}); | 125 [const Symbol("x"), 42]); |
| 126 testInvocationMirror(c(37, x: 42), const Symbol('call'), [37], |
| 127 [const Symbol("x"), 42]); |
107 | 128 |
108 // Wrong arguments to existing function. | 129 // Wrong arguments to existing function. |
109 testInvocationMirror(n.flif(), "flif", [], {}); | 130 testInvocationMirror(n.flif(), const Symbol("flif"), [], []); |
110 testInvocationMirror(n.flif(37, 42), "flif", [37, 42], {}); | 131 testInvocationMirror(n.flif(37, 42), const Symbol("flif"), [37, 42], []); |
111 testInvocationMirror(n.flif(x: 42), "flif", [], {"x": 42}); | 132 testInvocationMirror(n.flif(x: 42), const Symbol("flif"), [], |
112 testInvocationMirror(n.flif(37, x: 42), "flif", [37], {"x": 42}); | 133 [const Symbol("x"), 42]); |
113 testInvocationMirror((n..flif = 42).last, "flif=", [42]); | 134 testInvocationMirror(n.flif(37, x: 42), const Symbol("flif"), [37], |
| 135 [const Symbol("x"), 42]); |
| 136 testInvocationMirror((n..flif = 42).last, const Symbol("flif="), [42]); |
114 | 137 |
115 testInvocationMirror(n.flaf(37, 42), "flaf", [37, 42], {}); | 138 testInvocationMirror(n.flaf(37, 42), const Symbol("flaf"), [37, 42], []); |
116 testInvocationMirror(n.flaf(x: 42), "flaf", [], {"x": 42}); | 139 testInvocationMirror(n.flaf(x: 42), const Symbol("flaf"), [], |
117 testInvocationMirror(n.flaf(37, x: 42), "flaf", [37], {"x": 42}); | 140 [const Symbol("x"), 42]); |
118 testInvocationMirror((n..flaf = 42).last, "flaf=", [42]); | 141 testInvocationMirror(n.flaf(37, x: 42), const Symbol("flaf"), [37], |
| 142 [const Symbol("x"), 42]); |
| 143 testInvocationMirror((n..flaf = 42).last, const Symbol("flaf="), [42]); |
119 | 144 |
120 testInvocationMirror(n.flof(37, 42), "flof", [37, 42], {}); | 145 testInvocationMirror(n.flof(37, 42), const Symbol("flof"), [37, 42], []); |
121 testInvocationMirror(n.flof(x: 42), "flof", [], {"x": 42}); | 146 testInvocationMirror(n.flof(x: 42), const Symbol("flof"), [], |
122 testInvocationMirror(n.flof(37, y: 42), "flof", [37], {"y": 42}); | 147 [const Symbol("x"), 42]); |
123 testInvocationMirror((n..flof = 42).last, "flof=", [42]); | 148 testInvocationMirror(n.flof(37, y: 42), const Symbol("flof"), [37], |
| 149 [const Symbol("y"), 42]); |
| 150 testInvocationMirror((n..flof = 42).last, const Symbol("flof="), [42]); |
124 | 151 |
125 // Reading works. | 152 // Reading works. |
126 Expect.isTrue(n.flif is Function); | 153 Expect.isTrue(n.flif is Function); |
127 Expect.isTrue(n.flaf is Function); | 154 Expect.isTrue(n.flaf is Function); |
128 Expect.isTrue(n.flof is Function); | 155 Expect.isTrue(n.flof is Function); |
129 | 156 |
130 // Writing to read-only fields. | 157 // Writing to read-only fields. |
131 testInvocationMirror((n..wut = 42).last, "wut=", [42]); | 158 testInvocationMirror((n..wut = 42).last, const Symbol("wut="), [42]); |
132 testInvocationMirror((n..plif = 42).last, "plif=", [42]); | 159 testInvocationMirror((n..plif = 42).last, const Symbol("plif="), [42]); |
133 testInvocationMirror((n..plaf = 42).last, "plaf=", [42]); | 160 testInvocationMirror((n..plaf = 42).last, const Symbol("plaf="), [42]); |
134 | 161 |
135 // Trick call to n.call - wut is a getter returning n again. | 162 // Trick call to n.call - wut is a getter returning n again. |
136 testInvocationMirror(n.wut(42), "call", [42], {}); | 163 testInvocationMirror(n.wut(42), const Symbol("call"), [42], []); |
137 | 164 |
138 // Calling noSuchMethod itself, badly. | 165 // Calling noSuchMethod itself, badly. |
139 testInvocationMirror(n.noSuchMethod(), "noSuchMethod", [], {}); | 166 testInvocationMirror(n.noSuchMethod(), const Symbol("noSuchMethod"), [], []); |
140 testInvocationMirror(n.noSuchMethod(37, 42), "noSuchMethod", [37, 42], {}); | 167 testInvocationMirror(n.noSuchMethod(37, 42), const Symbol("noSuchMethod"), |
| 168 [37, 42], []); |
141 testInvocationMirror(n.noSuchMethod(37, x:42), | 169 testInvocationMirror(n.noSuchMethod(37, x:42), |
142 "noSuchMethod", [37], {"x": 42}); | 170 const Symbol("noSuchMethod"), [37], |
143 testInvocationMirror(n.noSuchMethod(x:42), "noSuchMethod", [], {"x": 42}); | 171 [const Symbol("x"), 42]); |
| 172 testInvocationMirror(n.noSuchMethod(x:42), const Symbol("noSuchMethod"), [], |
| 173 [const Symbol("x"), 42]); |
144 | 174 |
145 // Closurizing a method means that calling it badly will not hit the | 175 // Closurizing a method means that calling it badly will not hit the |
146 // original receivers noSuchMethod, only the one inherited from Object | 176 // original receivers noSuchMethod, only the one inherited from Object |
147 // by the closure object. | 177 // by the closure object. |
148 Expect.throws(() { var x = n.flif; x(37, 42); }, | 178 Expect.throws(() { var x = n.flif; x(37, 42); }, |
149 (e) => e is NoSuchMethodError); | 179 (e) => e is NoSuchMethodError); |
150 Expect.throws(() { var x = c.call; x(37, 42); }, | 180 Expect.throws(() { var x = c.call; x(37, 42); }, |
151 (e) => e is NoSuchMethodError); | 181 (e) => e is NoSuchMethodError); |
152 } | 182 } |
153 | 183 |
154 class M extends N { | 184 class M extends N { |
155 noSuchMethod(Invocation m) { throw "never get here"; } | 185 noSuchMethod(Invocation m) { throw "never get here"; } |
156 | 186 |
157 testSuperCalls() { | 187 testSuperCalls() { |
158 // Missing property/method access. | 188 // Missing property/method access. |
159 testInvocationMirror(super.bar, 'bar'); | 189 testInvocationMirror(super.bar, const Symbol('bar')); |
160 testInvocationMirror((){super.bar = 42; return last;}(), 'bar=', [42]); | 190 testInvocationMirror((){super.bar = 42; return last;}(), |
161 testInvocationMirror(super.bar(), 'bar', [], {}); | 191 const Symbol('bar='), [42]); |
162 testInvocationMirror(super.bar(42), 'bar', [42], {}); | 192 testInvocationMirror(super.bar(), const Symbol('bar'), [], []); |
163 testInvocationMirror(super.bar(x: 42), 'bar', [], {"x": 42}); | 193 testInvocationMirror(super.bar(42), const Symbol('bar'), [42], []); |
164 testInvocationMirror(super.bar(37, x: 42), 'bar', [37], {"x": 42}); | 194 testInvocationMirror(super.bar(x: 42), const Symbol('bar'), [], |
| 195 [const Symbol("x"), 42]); |
| 196 testInvocationMirror(super.bar(37, x: 42), const Symbol('bar'), [37], |
| 197 [const Symbol("x"), 42]); |
165 | 198 |
166 // Missing operator access. | 199 // Missing operator access. |
167 testInvocationMirror(super + 4, '+', [4], {}); | 200 testInvocationMirror(super + 4, const Symbol('+'), [4], []); |
168 testInvocationMirror(super - 4, '-', [4], {}); | 201 testInvocationMirror(super - 4, const Symbol('-'), [4], []); |
169 testInvocationMirror(-super, 'unary-', [], {}); | 202 testInvocationMirror(-super, const Symbol('unary-'), [], []); |
170 testInvocationMirror(super[42], '[]', [42], {}); | 203 testInvocationMirror(super[42], const Symbol('[]'), [42], []); |
171 testInvocationMirror((){super[37] = 42; return last;}(), '[]=', [37, 42], {}
); | 204 testInvocationMirror((){super[37] = 42; return last;}(), |
| 205 const Symbol('[]='), [37, 42], []); |
172 | 206 |
173 // Wrong arguments to existing function. | 207 // Wrong arguments to existing function. |
174 testInvocationMirror(super.flif(), "flif", [], {}); | 208 testInvocationMirror(super.flif(), const Symbol("flif"), [], []); |
175 testInvocationMirror(super.flif(37, 42), "flif", [37, 42], {}); | 209 testInvocationMirror(super.flif(37, 42), const Symbol("flif"), [37, 42], |
176 testInvocationMirror(super.flif(x: 42), "flif", [], {"x": 42}); | 210 []); |
177 testInvocationMirror(super.flif(37, x: 42), "flif", [37], {"x": 42}); | 211 testInvocationMirror(super.flif(x: 42), const Symbol("flif"), [], |
178 testInvocationMirror((){super.flif = 42; return last;}(), "flif=", [42]); | 212 [const Symbol("x"), 42]); |
| 213 testInvocationMirror(super.flif(37, x: 42), const Symbol("flif"), [37], |
| 214 [const Symbol("x"), 42]); |
| 215 testInvocationMirror((){super.flif = 42; return last;}(), |
| 216 const Symbol("flif="), [42]); |
179 | 217 |
180 testInvocationMirror(super.flaf(37, 42), "flaf", [37, 42], {}); | 218 testInvocationMirror(super.flaf(37, 42), const Symbol("flaf"), [37, 42], |
181 testInvocationMirror(super.flaf(x: 42), "flaf", [], {"x": 42}); | 219 []); |
182 testInvocationMirror(super.flaf(37, x: 42), "flaf", [37], {"x": 42}); | 220 testInvocationMirror(super.flaf(x: 42), const Symbol("flaf"), [], |
183 testInvocationMirror((){super.flaf = 42; return last;}(), "flaf=", [42]); | 221 [const Symbol("x"), 42]); |
| 222 testInvocationMirror(super.flaf(37, x: 42), const Symbol("flaf"), [37], |
| 223 [const Symbol("x"), 42]); |
| 224 testInvocationMirror((){super.flaf = 42; return last;}(), |
| 225 const Symbol("flaf="), [42]); |
184 | 226 |
185 testInvocationMirror(super.flof(37, 42), "flof", [37, 42], {}); | 227 testInvocationMirror(super.flof(37, 42), const Symbol("flof"), [37, 42], |
186 testInvocationMirror(super.flof(x: 42), "flof", [], {"x": 42}); | 228 []); |
187 testInvocationMirror(super.flof(37, y: 42), "flof", [37], {"y": 42}); | 229 testInvocationMirror(super.flof(x: 42), const Symbol("flof"), [], |
188 testInvocationMirror((){super.flof = 42; return last;}(), "flof=", [42]); | 230 [const Symbol("x"), 42]); |
| 231 testInvocationMirror(super.flof(37, y: 42), const Symbol("flof"), [37], |
| 232 [const Symbol("y"), 42]); |
| 233 testInvocationMirror((){super.flof = 42; return last;}(), |
| 234 const Symbol("flof="), [42]); |
189 | 235 |
190 // Reading works. | 236 // Reading works. |
191 Expect.isTrue(super.flif is Function); | 237 Expect.isTrue(super.flif is Function); |
192 Expect.isTrue(super.flaf is Function); | 238 Expect.isTrue(super.flaf is Function); |
193 Expect.isTrue(super.flof is Function); | 239 Expect.isTrue(super.flof is Function); |
194 | 240 |
195 // Writing to read-only fields. | 241 // Writing to read-only fields. |
196 testInvocationMirror((){super.wut = 42; return last;}(), "wut=", [42]); | 242 testInvocationMirror((){super.wut = 42; return last;}(), |
197 testInvocationMirror((){super.plif = 42; return last;}(), "plif=", [42]); | 243 const Symbol("wut="), [42]); |
198 testInvocationMirror((){super.plaf = 42; return last;}(), "plaf=", [42]); | 244 testInvocationMirror((){super.plif = 42; return last;}(), |
| 245 const Symbol("plif="), [42]); |
| 246 testInvocationMirror((){super.plaf = 42; return last;}(), |
| 247 const Symbol("plaf="), [42]); |
199 | 248 |
200 // Calling noSuchMethod itself, badly. | 249 // Calling noSuchMethod itself, badly. |
201 testInvocationMirror(super.noSuchMethod(), "noSuchMethod", [], {}); | 250 testInvocationMirror(super.noSuchMethod(), const Symbol("noSuchMethod"), [], |
| 251 []); |
202 testInvocationMirror(super.noSuchMethod(37, 42), | 252 testInvocationMirror(super.noSuchMethod(37, 42), |
203 "noSuchMethod", [37, 42], {}); | 253 const Symbol("noSuchMethod"), [37, 42], []); |
204 testInvocationMirror(super.noSuchMethod(37, x:42), | 254 testInvocationMirror(super.noSuchMethod(37, x:42), |
205 "noSuchMethod", [37], {"x": 42}); | 255 const Symbol("noSuchMethod"), [37], |
| 256 [const Symbol("x"), 42]); |
206 testInvocationMirror(super.noSuchMethod(x:42), | 257 testInvocationMirror(super.noSuchMethod(x:42), |
207 "noSuchMethod", [], {"x": 42}); | 258 const Symbol("noSuchMethod"), [], |
| 259 [const Symbol("x"), 42]); |
208 | 260 |
209 // Closurizing a method means that calling it badly will not hit the | 261 // Closurizing a method means that calling it badly will not hit the |
210 // original receivers noSuchMethod, only the one inherited from Object | 262 // original receivers noSuchMethod, only the one inherited from Object |
211 // by the closure object. | 263 // by the closure object. |
212 Expect.throws(() { var x = super.flif; x(37, 42); }, | 264 Expect.throws(() { var x = super.flif; x(37, 42); }, |
213 (e) => e is NoSuchMethodError); | 265 (e) => e is NoSuchMethodError); |
214 } | 266 } |
215 } | 267 } |
216 | 268 |
217 | 269 |
(...skipping 19 matching lines...) Expand all Loading... |
237 test(() => o.hashCode = 42); | 289 test(() => o.hashCode = 42); |
238 test(() => o.hashCode()); // Thrown by int.noSuchMethod. | 290 test(() => o.hashCode()); // Thrown by int.noSuchMethod. |
239 test(() => (n.flif)()); // Extracted method has no noSuchMethod. | 291 test(() => (n.flif)()); // Extracted method has no noSuchMethod. |
240 } | 292 } |
241 | 293 |
242 main() { | 294 main() { |
243 testInvocationMirrors(); | 295 testInvocationMirrors(); |
244 testNoSuchMethodErrors(); | 296 testNoSuchMethodErrors(); |
245 new M().testSuperCalls(); | 297 new M().testSuperCalls(); |
246 } | 298 } |
OLD | NEW |