| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // TODO(rmacnak): Move the existing mirror tests here (a place for | 5 // TODO(rmacnak): Move the existing mirror tests here (a place for |
| 6 // cross-implementation tests). | 6 // cross-implementation tests). |
| 7 | 7 |
| 8 #library("MirrorsTest.dart"); | 8 #library("MirrorsTest.dart"); |
| 9 #import("dart:mirrors"); | 9 #import("dart:mirrors"); |
| 10 #import("../../../pkg/unittest/unittest.dart"); | 10 #import("../../../pkg/unittest/unittest.dart"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 expect(instance.field, equals(44)); | 46 expect(instance.field, equals(44)); |
| 47 })); | 47 })); |
| 48 } | 48 } |
| 49 | 49 |
| 50 testClosureMirrors(mirrors) { | 50 testClosureMirrors(mirrors) { |
| 51 var closure = (x, y, z) { return x + y + z; }; | 51 var closure = (x, y, z) { return x + y + z; }; |
| 52 | 52 |
| 53 var mirror = reflect(closure); | 53 var mirror = reflect(closure); |
| 54 expect(mirror is ClosureMirror, equals(true)); | 54 expect(mirror is ClosureMirror, equals(true)); |
| 55 | 55 |
| 56 var funcMirror = mirror.function(); | 56 var funcMirror = mirror.function; |
| 57 expect(funcMirror is MethodMirror, equals(true)); | 57 expect(funcMirror is MethodMirror, equals(true)); |
| 58 expect(funcMirror.parameters.length, equals(3)); | 58 expect(funcMirror.parameters.length, equals(3)); |
| 59 | 59 |
| 60 var future = mirror.apply([2, 4, 8]); | 60 var future = mirror.apply([2, 4, 8]); |
| 61 future.then(expectAsync1((resultMirror) { | 61 future.then(expectAsync1((resultMirror) { |
| 62 expect(resultMirror.reflectee, equals(14)); | 62 expect(resultMirror.reflectee, equals(14)); |
| 63 })); | 63 })); |
| 64 } | 64 } |
| 65 | 65 |
| 66 testInvokeConstructor(mirrors) { | 66 testInvokeConstructor(mirrors) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 main() { | 85 main() { |
| 86 var mirrors = currentMirrorSystem(); | 86 var mirrors = currentMirrorSystem(); |
| 87 | 87 |
| 88 test("Test field access", () { testFieldAccess(mirrors); }); | 88 test("Test field access", () { testFieldAccess(mirrors); }); |
| 89 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); | 89 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); |
| 90 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); | 90 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); |
| 91 } | 91 } |
| 92 | 92 |
| OLD | NEW |