| 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 library MirrorsTest; | 5 library MirrorsTest; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import '../../light_unittest.dart'; | 9 import '../../light_unittest.dart'; |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 expect(classMirror.invoke(const Symbol("s"),['A', 'B', instance]).reflectee, | 53 expect(classMirror.invoke(const Symbol("s"),['A', 'B', instance]).reflectee, |
| 54 equals({"a": 'A', "b":'B', "c": instance})); | 54 equals({"a": 'A', "b":'B', "c": instance})); |
| 55 expect(() => classMirror.invoke(const Symbol("notDefined"), []).reflectee, | 55 expect(() => classMirror.invoke(const Symbol("notDefined"), []).reflectee, |
| 56 throws); | 56 throws); |
| 57 expect(() => classMirror.invoke(const Symbol("s"), []).reflectee, | 57 expect(() => classMirror.invoke(const Symbol("s"), []).reflectee, |
| 58 throws); // Wrong arity. | 58 throws); // Wrong arity. |
| 59 // TODO(rmacnak): Implement access to private members. | 59 // TODO(rmacnak): Implement access to private members. |
| 60 // expect(classMirror.invoke(const Symbol("_t"), [3, 4]).reflectee, | 60 // expect(classMirror.invoke(const Symbol("_t"), [3, 4]).reflectee, |
| 61 // equals(7)); | 61 // equals(7)); |
| 62 | 62 |
| 63 if (isDart2js) return; | |
| 64 | |
| 65 var libMirror = classMirror.owner; | 63 var libMirror = classMirror.owner; |
| 66 expect(libMirror.invoke(const Symbol("u"),['A', 'B', instance]).reflectee, | 64 expect(libMirror.invoke(const Symbol("u"),['A', 'B', instance]).reflectee, |
| 67 equals({"a": 'A', "b":'B', "c": instance})); | 65 equals({"a": 'A', "b":'B', "c": instance})); |
| 68 expect(() => libMirror.invoke(const Symbol("notDefined"), []).reflectee, | 66 expect(() => libMirror.invoke(const Symbol("notDefined"), []).reflectee, |
| 69 throws); | 67 throws); |
| 70 expect(() => libMirror.invoke(const Symbol("u"), []).reflectee, | 68 expect(() => libMirror.invoke(const Symbol("u"), []).reflectee, |
| 71 throws); // Wrong arity. | 69 throws); // Wrong arity. |
| 72 // NB: This works on the VM but fails at compile-time on dart2js. | 70 // NB: This works on the VM but fails at compile-time on dart2js. |
| 73 // expect(libMirror.invoke(const Symbol("_v"), [3, 4]).reflectee, | 71 // expect(libMirror.invoke(const Symbol("_v"), [3, 4]).reflectee, |
| 74 // equals(7)); | 72 // equals(7)); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 test("Test current library uri", () { | 285 test("Test current library uri", () { |
| 288 testLibraryUri(new Class(), | 286 testLibraryUri(new Class(), |
| 289 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); | 287 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); |
| 290 }); | 288 }); |
| 291 test("Test dart library uri", () { | 289 test("Test dart library uri", () { |
| 292 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); | 290 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); |
| 293 }); | 291 }); |
| 294 test("Test simple and qualifiedName", () { testNames(mirrors); }); | 292 test("Test simple and qualifiedName", () { testNames(mirrors); }); |
| 295 test("Test reflect type", () { testReflectClass(mirrors); }); | 293 test("Test reflect type", () { testReflectClass(mirrors); }); |
| 296 } | 294 } |
| OLD | NEW |