| 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; | 9 import 'dart:async' show Future; |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 Expect.equals('X-null-null', result.reflectee); | 70 Expect.equals('X-null-null', result.reflectee); |
| 71 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'}); |
| 72 Expect.equals('X-Y-Z', result.reflectee); | 72 Expect.equals('X-Y-Z', result.reflectee); |
| 73 Expect.throws(() => om.invoke(const Symbol('b'), ['X']), | 73 Expect.throws(() => om.invoke(const Symbol('b'), ['X']), |
| 74 isNoSuchMethodError, | 74 isNoSuchMethodError, |
| 75 'Extra positional arguments'); | 75 'Extra positional arguments'); |
| 76 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'}), |
| 77 isNoSuchMethodError, | 77 isNoSuchMethodError, |
| 78 'Unmatched named argument'); | 78 'Unmatched named argument'); |
| 79 | 79 |
| 80 if (!isDart2js) { | |
| 81 result = om.invoke(const Symbol('c'), ['X']); | 80 result = om.invoke(const Symbol('c'), ['X']); |
| 82 Expect.equals('X-null-C', result.reflectee); | 81 Expect.equals('X-null-C', result.reflectee); |
| 83 result = om.invoke(const Symbol('c'), ['X', 'Y']); | 82 result = om.invoke(const Symbol('c'), ['X', 'Y']); |
| 84 Expect.equals('X-Y-C', result.reflectee); | 83 Expect.equals('X-Y-C', result.reflectee); |
| 85 result = om.invoke(const Symbol('c'), ['X', 'Y', 'Z']); | 84 result = om.invoke(const Symbol('c'), ['X', 'Y', 'Z']); |
| 86 Expect.equals('X-Y-Z', result.reflectee); | 85 Expect.equals('X-Y-Z', result.reflectee); |
| 87 Expect.throws(() => om.invoke(const Symbol('c'), []), | 86 Expect.throws(() => om.invoke(const Symbol('c'), []), |
| 88 isNoSuchMethodError, | 87 isNoSuchMethodError, |
| 89 'Insufficient positional arguments'); | 88 'Insufficient positional arguments'); |
| 90 Expect.throws(() => om.invoke(const Symbol('c'), ['X', 'Y', 'Z', 'W']), | 89 Expect.throws(() => om.invoke(const Symbol('c'), ['X', 'Y', 'Z', 'W']), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 result = om.invoke(const Symbol('d'), ['X', 'Y']); | 100 result = om.invoke(const Symbol('d'), ['X', 'Y']); |
| 102 Expect.equals('X-Y-C', result.reflectee); | 101 Expect.equals('X-Y-C', result.reflectee); |
| 103 result = om.invoke(const Symbol('d'), ['X', 'Y', 'Z']); | 102 result = om.invoke(const Symbol('d'), ['X', 'Y', 'Z']); |
| 104 Expect.equals('X-Y-Z', result.reflectee); | 103 Expect.equals('X-Y-Z', result.reflectee); |
| 105 Expect.throws(() => om.invoke(const Symbol('d'), ['X', 'Y', 'Z', 'W']), | 104 Expect.throws(() => om.invoke(const Symbol('d'), ['X', 'Y', 'Z', 'W']), |
| 106 isNoSuchMethodError, | 105 isNoSuchMethodError, |
| 107 'Extra positional arguments'); | 106 'Extra positional arguments'); |
| 108 Expect.throws(() => om.invoke(const Symbol('d'), ['X'], {const Symbol('undef')
: 'Y'}), | 107 Expect.throws(() => om.invoke(const Symbol('d'), ['X'], {const Symbol('undef')
: 'Y'}), |
| 109 isNoSuchMethodError, | 108 isNoSuchMethodError, |
| 110 'Unmatched named argument'); | 109 'Unmatched named argument'); |
| 111 } | |
| 112 | 110 |
| 113 result = om.invoke(const Symbol('e'), ['X', 'Y', 'Z']); | 111 result = om.invoke(const Symbol('e'), ['X', 'Y', 'Z']); |
| 114 Expect.equals('X-Y-Z', result.reflectee); | 112 Expect.equals('X-Y-Z', result.reflectee); |
| 115 Expect.throws(() => om.invoke(const Symbol('e'), ['X']), | 113 Expect.throws(() => om.invoke(const Symbol('e'), ['X']), |
| 116 isNoSuchMethodError, | 114 isNoSuchMethodError, |
| 117 'Insufficient positional arguments'); | 115 'Insufficient positional arguments'); |
| 118 Expect.throws(() => om.invoke(const Symbol('e'), ['X', 'Y', 'Z', 'W']), | 116 Expect.throws(() => om.invoke(const Symbol('e'), ['X', 'Y', 'Z', 'W']), |
| 119 isNoSuchMethodError, | 117 isNoSuchMethodError, |
| 120 'Extra positional arguments'); | 118 'Extra positional arguments'); |
| 121 Expect.throws(() => om.invoke(const Symbol('e'), ['X'], {const Symbol('undef')
: 'Y'}), | 119 Expect.throws(() => om.invoke(const Symbol('e'), ['X'], {const Symbol('undef')
: 'Y'}), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }); | 154 }); |
| 157 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); | 155 future = om.invokeAsync(const Symbol('b'), [], {const Symbol('b') :'Y', const
Symbol('c') :'Z', const Symbol('a') :'X'}); |
| 158 expectValueThen(future, (result) { | 156 expectValueThen(future, (result) { |
| 159 Expect.equals('X-Y-Z', result.reflectee); | 157 Expect.equals('X-Y-Z', result.reflectee); |
| 160 }); | 158 }); |
| 161 future = om.invokeAsync(const Symbol('b'), ['X']); | 159 future = om.invokeAsync(const Symbol('b'), ['X']); |
| 162 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 160 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 163 future = om.invokeAsync(const Symbol('b'), ['X'], {const Symbol('undef'): 'Y'}
); | 161 future = om.invokeAsync(const Symbol('b'), ['X'], {const Symbol('undef'): 'Y'}
); |
| 164 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 162 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 165 | 163 |
| 166 if (!isDart2js) { | |
| 167 future = om.invokeAsync(const Symbol('c'), ['X']); | 164 future = om.invokeAsync(const Symbol('c'), ['X']); |
| 168 expectValueThen(future, (result) { | 165 expectValueThen(future, (result) { |
| 169 Expect.equals('X-null-C', result.reflectee); | 166 Expect.equals('X-null-C', result.reflectee); |
| 170 }); | 167 }); |
| 171 future = om.invokeAsync(const Symbol('c'), ['X', 'Y']); | 168 future = om.invokeAsync(const Symbol('c'), ['X', 'Y']); |
| 172 expectValueThen(future, (result) { | 169 expectValueThen(future, (result) { |
| 173 Expect.equals('X-Y-C', result.reflectee); | 170 Expect.equals('X-Y-C', result.reflectee); |
| 174 }); | 171 }); |
| 175 future = om.invokeAsync(const Symbol('c'), ['X', 'Y', 'Z']); | 172 future = om.invokeAsync(const Symbol('c'), ['X', 'Y', 'Z']); |
| 176 expectValueThen(future, (result) { | 173 expectValueThen(future, (result) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 197 Expect.equals('X-Y-C', result.reflectee); | 194 Expect.equals('X-Y-C', result.reflectee); |
| 198 }); | 195 }); |
| 199 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z']); | 196 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z']); |
| 200 expectValueThen(future, (result) { | 197 expectValueThen(future, (result) { |
| 201 Expect.equals('X-Y-Z', result.reflectee); | 198 Expect.equals('X-Y-Z', result.reflectee); |
| 202 }); | 199 }); |
| 203 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z', 'W']); | 200 future = om.invokeAsync(const Symbol('d'), ['X', 'Y', 'Z', 'W']); |
| 204 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 201 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 205 future = om.invokeAsync(const Symbol('d'), ['X'], {const Symbol('undef'): 'Y'}
); | 202 future = om.invokeAsync(const Symbol('d'), ['X'], {const Symbol('undef'): 'Y'}
); |
| 206 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); | 203 expectError(future, isNoSuchMethodError, 'Unmatched named argument'); |
| 207 } | |
| 208 | 204 |
| 209 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z']); | 205 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z']); |
| 210 expectValueThen(future, (result) { | 206 expectValueThen(future, (result) { |
| 211 Expect.equals('X-Y-Z', result.reflectee); | 207 Expect.equals('X-Y-Z', result.reflectee); |
| 212 }); | 208 }); |
| 213 future = om.invokeAsync(const Symbol('e'), ['X']); | 209 future = om.invokeAsync(const Symbol('e'), ['X']); |
| 214 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); | 210 expectError(future, isNoSuchMethodError, 'Insufficient positional arguments'); |
| 215 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z', 'W']); | 211 future = om.invokeAsync(const Symbol('e'), ['X', 'Y', 'Z', 'W']); |
| 216 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); | 212 expectError(future, isNoSuchMethodError, 'Extra positional arguments'); |
| 217 future = om.invokeAsync(const Symbol('e'), ['X'], {const Symbol('undef'): 'Y'}
); | 213 future = om.invokeAsync(const Symbol('e'), ['X'], {const Symbol('undef'): 'Y'}
); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 584 |
| 589 testAsyncInvoke(reflectClass(D)); // ClassMirror | 585 testAsyncInvoke(reflectClass(D)); // ClassMirror |
| 590 testAsyncInvoke(lib); // LibraryMirror | 586 testAsyncInvoke(lib); // LibraryMirror |
| 591 | 587 |
| 592 testSyncNewInstance(); | 588 testSyncNewInstance(); |
| 593 testAsyncNewInstance(); | 589 testAsyncNewInstance(); |
| 594 | 590 |
| 595 testSyncApply(); | 591 testSyncApply(); |
| 596 testAsyncApply(); | 592 testAsyncApply(); |
| 597 } | 593 } |
| OLD | NEW |