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 import 'dart:mirrors'; | 5 import 'dart:mirrors'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 import 'stringify.dart'; | 7 import 'stringify.dart'; |
8 | 8 |
9 testIntercepted() { | 9 testIntercepted() { |
10 var instance = []; | 10 var instance = []; |
11 var methodMirror = reflect(instance.toString); | 11 var closureMirror = reflect(instance.toString); |
12 String rest = ' in s(List)'; | 12 var methodMirror = closureMirror.function; |
13 rest = ''; /// 01: ok | 13 Expect.equals(#toString, methodMirror.simpleName); |
14 expect('Method(s(toString)$rest)', methodMirror.function); | 14 Expect.equals('[]', closureMirror.apply([]).reflectee); |
15 Expect.equals('[]', methodMirror.apply([]).reflectee); | |
16 } | 15 } |
17 | 16 |
18 testNonIntercepted() { | 17 testNonIntercepted() { |
19 var closure = new Map().containsKey; | 18 var closure = new Map().containsKey; |
20 var mirror = reflect(closure); | 19 var closureMirror = reflect(closure); |
21 String rest = ' in s(_HashMap)'; // Might become Map instead. | 20 var methodMirror = closureMirror.function; |
22 rest = ''; /// 01: ok | 21 Expect.equals(#containsKey, methodMirror.simpleName); |
23 expect('Method(s(containsKey)$rest)', mirror.function); | 22 Expect.isFalse(closureMirror.apply([7]).reflectee); |
24 Expect.isFalse(mirror.apply([7]).reflectee); | |
25 } | 23 } |
26 | 24 |
27 main() { | 25 main() { |
28 testIntercepted(); | 26 testIntercepted(); |
29 testNonIntercepted(); | 27 testNonIntercepted(); |
30 } | 28 } |
OLD | NEW |