| 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_named_test; | 5 library test.invoke_named_test; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'dart:async' show Future; |
| 10 |
| 9 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 10 import 'invoke_test.dart'; | 12 import 'invoke_test.dart'; |
| 11 | 13 |
| 14 // TODO(ahe): Remove this variable (http://dartbug.com/12863). |
| 15 bool isDart2js = false; |
| 16 |
| 12 class C { | 17 class C { |
| 13 a(a, {b:'B', c}) => "$a-$b-$c"; | 18 a(a, {b:'B', c}) => "$a-$b-$c"; |
| 14 b({a:'A', b, c}) => "$a-$b-$c"; | 19 b({a:'A', b, c}) => "$a-$b-$c"; |
| 15 c(a, [b, c='C']) => "$a-$b-$c"; | 20 c(a, [b, c='C']) => "$a-$b-$c"; |
| 16 d([a, b='B', c='C']) => "$a-$b-$c"; | 21 d([a, b='B', c='C']) => "$a-$b-$c"; |
| 17 e(a, b, c) => "$a-$b-$c"; | 22 e(a, b, c) => "$a-$b-$c"; |
| 18 } | 23 } |
| 19 | 24 |
| 20 class D { | 25 class D { |
| 21 static a(a, {b:'B', c}) => "$a-$b-$c"; | 26 static a(a, {b:'B', c}) => "$a-$b-$c"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 51 Expect.equals('X-Y-Z', result.reflectee); | 56 Expect.equals('X-Y-Z', result.reflectee); |
| 52 Expect.throws(() => om.invoke(const Symbol('a'), []), | 57 Expect.throws(() => om.invoke(const Symbol('a'), []), |
| 53 isNoSuchMethodError, | 58 isNoSuchMethodError, |
| 54 'Insufficient positional arguments'); | 59 'Insufficient positional arguments'); |
| 55 Expect.throws(() => om.invoke(const Symbol('a'), ['X', 'Y']), | 60 Expect.throws(() => om.invoke(const Symbol('a'), ['X', 'Y']), |
| 56 isNoSuchMethodError, | 61 isNoSuchMethodError, |
| 57 'Extra positional arguments'); | 62 'Extra positional arguments'); |
| 58 Expect.throws(() => om.invoke(const Symbol('a'), ['X'], {const Symbol('undef')
: 'Y'}), | 63 Expect.throws(() => om.invoke(const Symbol('a'), ['X'], {const Symbol('undef')
: 'Y'}), |
| 59 isNoSuchMethodError, | 64 isNoSuchMethodError, |
| 60 'Unmatched named argument'); | 65 'Unmatched named argument'); |
| 61 | 66 |
| 62 result = om.invoke(const Symbol('b'), []); | 67 result = om.invoke(const Symbol('b'), []); |
| 63 Expect.equals('A-null-null', result.reflectee); | 68 Expect.equals('A-null-null', result.reflectee); |
| 64 result = om.invoke(const Symbol('b'), [], {const Symbol('a') : 'X'}); | 69 result = om.invoke(const Symbol('b'), [], {const Symbol('a') : 'X'}); |
| 65 Expect.equals('X-null-null', result.reflectee); | 70 Expect.equals('X-null-null', result.reflectee); |
| 66 result = om.invoke(const Symbol('b'), [], {const Symbol('b') :'Y', const Symbo
l('c') :'Z', const Symbol('a') :'X'}); | 71 result = om.invoke(const Symbol('b'), [], {const Symbol('b') :'Y', const Symbo
l('c') :'Z', const Symbol('a') :'X'}); |
| 67 Expect.equals('X-Y-Z', result.reflectee); | 72 Expect.equals('X-Y-Z', result.reflectee); |
| 68 Expect.throws(() => om.invoke(const Symbol('b'), ['X']), | 73 Expect.throws(() => om.invoke(const Symbol('b'), ['X']), |
| 69 isNoSuchMethodError, | 74 isNoSuchMethodError, |
| 70 'Extra positional arguments'); | 75 'Extra positional arguments'); |
| 71 Expect.throws(() => om.invoke(const Symbol('b'), ['X'], {const Symbol('undef')
: 'Y'}), | 76 Expect.throws(() => om.invoke(const Symbol('b'), ['X'], {const Symbol('undef')
: 'Y'}), |
| 72 isNoSuchMethodError, | 77 isNoSuchMethodError, |
| 73 'Unmatched named argument'); | 78 'Unmatched named argument'); |
| 74 | 79 |
| 80 if (!isDart2js) { |
| 75 result = om.invoke(const Symbol('c'), ['X']); | 81 result = om.invoke(const Symbol('c'), ['X']); |
| 76 Expect.equals('X-null-C', result.reflectee); | 82 Expect.equals('X-null-C', result.reflectee); |
| 77 result = om.invoke(const Symbol('c'), ['X', 'Y']); | 83 result = om.invoke(const Symbol('c'), ['X', 'Y']); |
| 78 Expect.equals('X-Y-C', result.reflectee); | 84 Expect.equals('X-Y-C', result.reflectee); |
| 79 result = om.invoke(const Symbol('c'), ['X', 'Y', 'Z']); | 85 result = om.invoke(const Symbol('c'), ['X', 'Y', 'Z']); |
| 80 Expect.equals('X-Y-Z', result.reflectee); | 86 Expect.equals('X-Y-Z', result.reflectee); |
| 81 Expect.throws(() => om.invoke(const Symbol('c'), []), | 87 Expect.throws(() => om.invoke(const Symbol('c'), []), |
| 82 isNoSuchMethodError, | 88 isNoSuchMethodError, |
| 83 'Insufficient positional arguments'); | 89 'Insufficient positional arguments'); |
| 84 Expect.throws(() => om.invoke(const Symbol('c'), ['X', 'Y', 'Z', 'W']), | 90 Expect.throws(() => om.invoke(const Symbol('c'), ['X', 'Y', 'Z', 'W']), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 result = om.invoke(const Symbol('d'), ['X', 'Y']); | 101 result = om.invoke(const Symbol('d'), ['X', 'Y']); |
| 96 Expect.equals('X-Y-C', result.reflectee); | 102 Expect.equals('X-Y-C', result.reflectee); |
| 97 result = om.invoke(const Symbol('d'), ['X', 'Y', 'Z']); | 103 result = om.invoke(const Symbol('d'), ['X', 'Y', 'Z']); |
| 98 Expect.equals('X-Y-Z', result.reflectee); | 104 Expect.equals('X-Y-Z', result.reflectee); |
| 99 Expect.throws(() => om.invoke(const Symbol('d'), ['X', 'Y', 'Z', 'W']), | 105 Expect.throws(() => om.invoke(const Symbol('d'), ['X', 'Y', 'Z', 'W']), |
| 100 isNoSuchMethodError, | 106 isNoSuchMethodError, |
| 101 'Extra positional arguments'); | 107 'Extra positional arguments'); |
| 102 Expect.throws(() => om.invoke(const Symbol('d'), ['X'], {const Symbol('undef')
: 'Y'}), | 108 Expect.throws(() => om.invoke(const Symbol('d'), ['X'], {const Symbol('undef')
: 'Y'}), |
| 103 isNoSuchMethodError, | 109 isNoSuchMethodError, |
| 104 'Unmatched named argument'); | 110 'Unmatched named argument'); |
| 111 } |
| 105 | 112 |
| 106 result = om.invoke(const Symbol('e'), ['X', 'Y', 'Z']); | 113 result = om.invoke(const Symbol('e'), ['X', 'Y', 'Z']); |
| 107 Expect.equals('X-Y-Z', result.reflectee); | 114 Expect.equals('X-Y-Z', result.reflectee); |
| 108 Expect.throws(() => om.invoke(const Symbol('e'), ['X']), | 115 Expect.throws(() => om.invoke(const Symbol('e'), ['X']), |
| 109 isNoSuchMethodError, | 116 isNoSuchMethodError, |
| 110 'Insufficient positional arguments'); | 117 'Insufficient positional arguments'); |
| 111 Expect.throws(() => om.invoke(const Symbol('e'), ['X', 'Y', 'Z', 'W']), | 118 Expect.throws(() => om.invoke(const Symbol('e'), ['X', 'Y', 'Z', 'W']), |
| 112 isNoSuchMethodError, | 119 isNoSuchMethodError, |
| 113 'Extra positional arguments'); | 120 'Extra positional arguments'); |
| 114 Expect.throws(() => om.invoke(const Symbol('e'), ['X'], {const Symbol('undef')
: 'Y'}), | 121 Expect.throws(() => om.invoke(const Symbol('e'), ['X'], {const Symbol('undef')
: 'Y'}), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 130 future = om.invokeAsync(const Symbol('a'), ['X'], {const Symbol('c') : 'Z', co
nst Symbol('b') : 'Y'}); | 137 future = om.invokeAsync(const Symbol('a'), ['X'], {const Symbol('c') : 'Z', co
nst Symbol('b') : 'Y'}); |
| 131 expectValueThen(future, (result) { | 138 expectValueThen(future, (result) { |
| 132 Expect.equals('X-Y-Z', result.reflectee); | 139 Expect.equals('X-Y-Z', result.reflectee); |
| 133 }); | 140 }); |
| 134 future = om.invokeAsync(const Symbol('a'), []); | 141 future = om.invokeAsync(const Symbol('a'), []); |
| 135 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 142 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 136 future = om.invokeAsync(const Symbol('a'), ['X', 'Y']); | 143 future = om.invokeAsync(const Symbol('a'), ['X', 'Y']); |
| 137 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 144 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 138 future = om.invokeAsync(const Symbol('a'), ['X'], {const Symbol('undef') : 'Y'
}); | 145 future = om.invokeAsync(const Symbol('a'), ['X'], {const Symbol('undef') : 'Y'
}); |
| 139 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 146 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 140 | 147 |
| 141 | 148 |
| 142 future = om.invokeAsync(const Symbol('b'), []); | 149 future = om.invokeAsync(const Symbol('b'), []); |
| 143 expectValueThen(future, (result) { | 150 expectValueThen(future, (result) { |
| 144 Expect.equals('A-null-null', result.reflectee); | 151 Expect.equals('A-null-null', result.reflectee); |
| 145 }); | 152 }); |
| 146 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('a') : 'X'}); | 153 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('a') : 'X'}); |
| 147 expectValueThen(future, (result) { | 154 expectValueThen(future, (result) { |
| 148 Expect.equals('X-null-null', result.reflectee); | 155 Expect.equals('X-null-null', result.reflectee); |
| 149 }); | 156 }); |
| 150 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); | 157 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); |
| 151 expectValueThen(future, (result) { | 158 expectValueThen(future, (result) { |
| 152 Expect.equals('X-Y-Z', result.reflectee); | 159 Expect.equals('X-Y-Z', result.reflectee); |
| 153 }); | 160 }); |
| 154 future = om.invokeAsync(const Symbol('b'), ['X']); | 161 future = om.invokeAsync(const Symbol('b'), ['X']); |
| 155 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 162 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 156 future = om.invokeAsync(const Symbol('b'), ['X'], {const Symbol('undef'): 'Y'}
); | 163 future = om.invokeAsync(const Symbol('b'), ['X'], {const Symbol('undef'): 'Y'}
); |
| 157 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 164 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 158 | 165 |
| 159 | 166 if (!isDart2js) { |
| 160 future = om.invokeAsync(const Symbol('c'), ['X']); | 167 future = om.invokeAsync(const Symbol('c'), ['X']); |
| 161 expectValueThen(future, (result) { | 168 expectValueThen(future, (result) { |
| 162 Expect.equals('X-null-C', result.reflectee); | 169 Expect.equals('X-null-C', result.reflectee); |
| 163 }); | 170 }); |
| 164 future = om.invokeAsync(const Symbol('c'), ['X', 'Y']); | 171 future = om.invokeAsync(const Symbol('c'), ['X', 'Y']); |
| 165 expectValueThen(future, (result) { | 172 expectValueThen(future, (result) { |
| 166 Expect.equals('X-Y-C', result.reflectee); | 173 Expect.equals('X-Y-C', result.reflectee); |
| 167 }); | 174 }); |
| 168 future = om.invokeAsync(const Symbol('c'), ['X', 'Y', 'Z']); | 175 future = om.invokeAsync(const Symbol('c'), ['X', 'Y', 'Z']); |
| 169 expectValueThen(future, (result) { | 176 expectValueThen(future, (result) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 190 Expect.equals('X-Y-C', result.reflectee); | 197 Expect.equals('X-Y-C', result.reflectee); |
| 191 }); | 198 }); |
| 192 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z']); | 199 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z']); |
| 193 expectValueThen(future, (result) { | 200 expectValueThen(future, (result) { |
| 194 Expect.equals('X-Y-Z', result.reflectee); | 201 Expect.equals('X-Y-Z', result.reflectee); |
| 195 }); | 202 }); |
| 196 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z', 'W']); | 203 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z', 'W']); |
| 197 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 204 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 198 future = om.invokeAsync(const Symbol('d'), ['X'], {const Symbol('undef'): 'Y'}
); | 205 future = om.invokeAsync(const Symbol('d'), ['X'], {const Symbol('undef'): 'Y'}
); |
| 199 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 206 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 200 | 207 } |
| 201 | 208 |
| 202 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z']); | 209 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z']); |
| 203 expectValueThen(future, (result) { | 210 expectValueThen(future, (result) { |
| 204 Expect.equals('X-Y-Z', result.reflectee); | 211 Expect.equals('X-Y-Z', result.reflectee); |
| 205 }); | 212 }); |
| 206 future = om.invokeAsync(const Symbol('e'), ['X']); | 213 future = om.invokeAsync(const Symbol('e'), ['X']); |
| 207 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 214 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 208 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z', 'W']); | 215 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z', 'W']); |
| 209 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 216 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 210 future = om.invokeAsync(const Symbol('e'), ['X'], {const Symbol('undef'): 'Y'}
); | 217 future = om.invokeAsync(const Symbol('e'), ['X'], {const Symbol('undef'): 'Y'}
); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 223 Expect.equals('X-Y-Z', result.reflectee.field); | 230 Expect.equals('X-Y-Z', result.reflectee.field); |
| 224 Expect.throws(() => cm.newInstance(const Symbol(''), []), | 231 Expect.throws(() => cm.newInstance(const Symbol(''), []), |
| 225 isNoSuchMethodError, | 232 isNoSuchMethodError, |
| 226 'Insufficient positional arguments'); | 233 'Insufficient positional arguments'); |
| 227 Expect.throws(() => cm.newInstance(const Symbol(''), ['X', 'Y']), | 234 Expect.throws(() => cm.newInstance(const Symbol(''), ['X', 'Y']), |
| 228 isNoSuchMethodError, | 235 isNoSuchMethodError, |
| 229 'Extra positional arguments'); | 236 'Extra positional arguments'); |
| 230 Expect.throws(() => cm.newInstance(const Symbol(''), ['X'], {const Symbol('und
ef') : 'Y'}), | 237 Expect.throws(() => cm.newInstance(const Symbol(''), ['X'], {const Symbol('und
ef') : 'Y'}), |
| 231 isNoSuchMethodError, | 238 isNoSuchMethodError, |
| 232 'Unmatched named argument'); | 239 'Unmatched named argument'); |
| 233 | 240 |
| 234 result = cm.newInstance(const Symbol('b'), []); | 241 result = cm.newInstance(const Symbol('b'), []); |
| 235 Expect.equals('A-null-null', result.reflectee.field); | 242 Expect.equals('A-null-null', result.reflectee.field); |
| 236 result = cm.newInstance(const Symbol('b'), [], {const Symbol('a') : 'X'}); | 243 result = cm.newInstance(const Symbol('b'), [], {const Symbol('a') : 'X'}); |
| 237 Expect.equals('X-null-null', result.reflectee.field); | 244 Expect.equals('X-null-null', result.reflectee.field); |
| 238 result = cm.newInstance(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); | 245 result = cm.newInstance(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); |
| 239 Expect.equals('X-Y-Z', result.reflectee.field); | 246 Expect.equals('X-Y-Z', result.reflectee.field); |
| 240 Expect.throws(() => cm.newInstance(const Symbol('b'), ['X']), | 247 Expect.throws(() => cm.newInstance(const Symbol('b'), ['X']), |
| 241 isNoSuchMethodError, | 248 isNoSuchMethodError, |
| 242 'Extra positional arguments'); | 249 'Extra positional arguments'); |
| 243 Expect.throws(() => cm.newInstance(const Symbol('b'), ['X'], {const Symbol('un
def'): 'Y'}), | 250 Expect.throws(() => cm.newInstance(const Symbol('b'), ['X'], {const Symbol('un
def'): 'Y'}), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 future = cm.newInstanceAsync(const Symbol(''), ['X'], {const Symbol('c') : 'Z'
, const Symbol('b') : 'Y'}); | 310 future = cm.newInstanceAsync(const Symbol(''), ['X'], {const Symbol('c') : 'Z'
, const Symbol('b') : 'Y'}); |
| 304 expectValueThen(future, (result) { | 311 expectValueThen(future, (result) { |
| 305 Expect.equals('X-Y-Z', result.reflectee.field); | 312 Expect.equals('X-Y-Z', result.reflectee.field); |
| 306 }); | 313 }); |
| 307 future = cm.newInstanceAsync(const Symbol(''), []); | 314 future = cm.newInstanceAsync(const Symbol(''), []); |
| 308 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 315 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 309 future = cm.newInstanceAsync(const Symbol(''), ['X', 'Y']); | 316 future = cm.newInstanceAsync(const Symbol(''), ['X', 'Y']); |
| 310 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 317 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 311 future = cm.newInstanceAsync(const Symbol(''), ['X'], {const Symbol('undef') :
'Y'}); | 318 future = cm.newInstanceAsync(const Symbol(''), ['X'], {const Symbol('undef') :
'Y'}); |
| 312 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 319 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 313 | 320 |
| 314 | 321 |
| 315 future = cm.newInstanceAsync(const Symbol('b'), []); | 322 future = cm.newInstanceAsync(const Symbol('b'), []); |
| 316 expectValueThen(future, (result) { | 323 expectValueThen(future, (result) { |
| 317 Expect.equals('A-null-null', result.reflectee.field); | 324 Expect.equals('A-null-null', result.reflectee.field); |
| 318 }); | 325 }); |
| 319 future = cm.newInstanceAsync(const Symbol('b'), [], {const Symbol('a') : 'X'})
; | 326 future = cm.newInstanceAsync(const Symbol('b'), [], {const Symbol('a') : 'X'})
; |
| 320 expectValueThen(future, (result) { | 327 expectValueThen(future, (result) { |
| 321 Expect.equals('X-null-null', result.reflectee.field); | 328 Expect.equals('X-null-null', result.reflectee.field); |
| 322 }); | 329 }); |
| 323 future = cm.newInstanceAsync(const Symbol('b'), [], {const Symbol('b') :'Y', c
onst Symbol('c') :'Z', const Symbol('a') :'X'}); | 330 future = cm.newInstanceAsync(const Symbol('b'), [], {const Symbol('b') :'Y', c
onst Symbol('c') :'Z', const Symbol('a') :'X'}); |
| 324 expectValueThen(future, (result) { | 331 expectValueThen(future, (result) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 Expect.equals('X-Y-Z', result.reflectee); | 404 Expect.equals('X-Y-Z', result.reflectee); |
| 398 Expect.throws(() => cm.apply([]), | 405 Expect.throws(() => cm.apply([]), |
| 399 isNoSuchMethodError, | 406 isNoSuchMethodError, |
| 400 'Insufficient positional arguments'); | 407 'Insufficient positional arguments'); |
| 401 Expect.throws(() => cm.apply(['X', 'Y']), | 408 Expect.throws(() => cm.apply(['X', 'Y']), |
| 402 isNoSuchMethodError, | 409 isNoSuchMethodError, |
| 403 'Extra positional arguments'); | 410 'Extra positional arguments'); |
| 404 Expect.throws(() => cm.apply(['X'], {const Symbol('undef') : 'Y'}), | 411 Expect.throws(() => cm.apply(['X'], {const Symbol('undef') : 'Y'}), |
| 405 isNoSuchMethodError, | 412 isNoSuchMethodError, |
| 406 'Unmatched named argument'); | 413 'Unmatched named argument'); |
| 407 | 414 |
| 408 cm = reflect(b); | 415 cm = reflect(b); |
| 409 result = cm.apply([]); | 416 result = cm.apply([]); |
| 410 Expect.equals('A-null-null', result.reflectee); | 417 Expect.equals('A-null-null', result.reflectee); |
| 411 result = cm.apply([], {const Symbol('a') : 'X'}); | 418 result = cm.apply([], {const Symbol('a') : 'X'}); |
| 412 Expect.equals('X-null-null', result.reflectee); | 419 Expect.equals('X-null-null', result.reflectee); |
| 413 result = cm.apply([], {const Symbol('b') :'Y', const Symbol('c') :'Z', const S
ymbol('a') :'X'}); | 420 result = cm.apply([], {const Symbol('b') :'Y', const Symbol('c') :'Z', const S
ymbol('a') :'X'}); |
| 414 Expect.equals('X-Y-Z', result.reflectee); | 421 Expect.equals('X-Y-Z', result.reflectee); |
| 415 Expect.throws(() => cm.apply(['X']), | 422 Expect.throws(() => cm.apply(['X']), |
| 416 isNoSuchMethodError, | 423 isNoSuchMethodError, |
| 417 'Extra positional arguments'); | 424 'Extra positional arguments'); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 future = cm.applyAsync(['X'], {const Symbol('c') : 'Z', const Symbol('b') : 'Y
'}); | 489 future = cm.applyAsync(['X'], {const Symbol('c') : 'Z', const Symbol('b') : 'Y
'}); |
| 483 expectValueThen(future, (result) { | 490 expectValueThen(future, (result) { |
| 484 Expect.equals('X-Y-Z', result.reflectee); | 491 Expect.equals('X-Y-Z', result.reflectee); |
| 485 }); | 492 }); |
| 486 future = cm.applyAsync([]); | 493 future = cm.applyAsync([]); |
| 487 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 494 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 488 future = cm.applyAsync(['X', 'Y']); | 495 future = cm.applyAsync(['X', 'Y']); |
| 489 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 496 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 490 future = cm.applyAsync(['X'], {const Symbol('undef') : 'Y'}); | 497 future = cm.applyAsync(['X'], {const Symbol('undef') : 'Y'}); |
| 491 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 498 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 492 | 499 |
| 493 | 500 |
| 494 cm = reflect(b); | 501 cm = reflect(b); |
| 495 future = cm.applyAsync([]); | 502 future = cm.applyAsync([]); |
| 496 expectValueThen(future, (result) { | 503 expectValueThen(future, (result) { |
| 497 Expect.equals('A-null-null', result.reflectee); | 504 Expect.equals('A-null-null', result.reflectee); |
| 498 }); | 505 }); |
| 499 future = cm.applyAsync([], {const Symbol('a') : 'X'}); | 506 future = cm.applyAsync([], {const Symbol('a') : 'X'}); |
| 500 expectValueThen(future, (result) { | 507 expectValueThen(future, (result) { |
| 501 Expect.equals('X-null-null', result.reflectee); | 508 Expect.equals('X-null-null', result.reflectee); |
| 502 }); | 509 }); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 }); | 568 }); |
| 562 future = cm.applyAsync(['X']); | 569 future = cm.applyAsync(['X']); |
| 563 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 570 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 564 future = cm.applyAsync(['X', 'Y', 'Z', 'W']); | 571 future = cm.applyAsync(['X', 'Y', 'Z', 'W']); |
| 565 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 572 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 566 future = cm.applyAsync(['X'], {const Symbol('undef'): 'Y'}); | 573 future = cm.applyAsync(['X'], {const Symbol('undef'): 'Y'}); |
| 567 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 574 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 568 } | 575 } |
| 569 | 576 |
| 570 main() { | 577 main() { |
| 571 testSyncInvoke(reflect(new C())); // InstanceMirror | 578 isDart2js = true; /// 01: ok |
| 572 testSyncInvoke(reflectClass(D)); // ClassMirror | |
| 573 testSyncInvoke(reflectClass(D).owner); // LibraryMirror | |
| 574 | 579 |
| 575 testAsyncInvoke(reflect(new C())); // InstanceMirror | 580 testSyncInvoke(reflect(new C())); // InstanceMirror |
| 576 testAsyncInvoke(reflectClass(D)); // ClassMirror | 581 if (!isDart2js) testSyncInvoke(reflectClass(D)); // ClassMirror |
| 577 testAsyncInvoke(reflectClass(D).owner); // LibraryMirror | 582 LibraryMirror lib = reflectClass(D).owner; |
| 583 if (!isDart2js) testSyncInvoke(lib); // LibraryMirror |
| 584 |
| 585 testAsyncInvoke(reflect(new C())); // InstanceMirror |
| 586 |
| 587 if (isDart2js) return; |
| 588 |
| 589 testAsyncInvoke(reflectClass(D)); // ClassMirror |
| 590 testAsyncInvoke(lib); // LibraryMirror |
| 578 | 591 |
| 579 testSyncNewInstance(); | 592 testSyncNewInstance(); |
| 580 testAsyncNewInstance(); | 593 testAsyncNewInstance(); |
| 581 | 594 |
| 582 testSyncApply(); | 595 testSyncApply(); |
| 583 testAsyncApply(); | 596 testAsyncApply(); |
| 584 } | 597 } |
| OLD | NEW |