OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Dart test program for checking implemention of MirrorSystem when | 5 // Dart test program for checking implemention of MirrorSystem when |
6 // inspecting the current isolate. | 6 // inspecting the current isolate. |
7 // | 7 // |
8 // VMOptions=--enable_type_checks | 8 // VMOptions=--enable_type_checks |
9 | 9 |
10 library isolate_mirror_local_test; | 10 library isolate_mirror_local_test; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 Expect.equals('Object', type_var.upperBound.simpleName); | 279 Expect.equals('Object', type_var.upperBound.simpleName); |
280 | 280 |
281 // Test typedef mirrors. | 281 // Test typedef mirrors. |
282 var typedef_mirror = lib_mirror.members['myFunc'].type; | 282 var typedef_mirror = lib_mirror.members['myFunc'].type; |
283 Expect.isTrue(typedef_mirror is TypedefMirror); | 283 Expect.isTrue(typedef_mirror is TypedefMirror); |
284 Expect.equals('isolate_mirror_local_test', typedef_mirror.owner.simpleName); | 284 Expect.equals('isolate_mirror_local_test', typedef_mirror.owner.simpleName); |
285 | 285 |
286 // Test function type mirrors. | 286 // Test function type mirrors. |
287 var func_cls_mirror = typedef_mirror.referent; | 287 var func_cls_mirror = typedef_mirror.referent; |
288 Expect.isTrue(func_cls_mirror is FunctionTypeMirror); | 288 Expect.isTrue(func_cls_mirror is FunctionTypeMirror); |
289 Expect.equals('void (dart:core.String)', func_cls_mirror.simpleName); | 289 Expect.equals('void (dart.core.String)', func_cls_mirror.simpleName); |
290 Expect.equals('void', func_cls_mirror.returnType.simpleName); | 290 Expect.equals('void', func_cls_mirror.returnType.simpleName); |
291 } | 291 } |
292 | 292 |
293 void testLibrariesMap(Map libraries) { | 293 void testLibrariesMap(Map libraries) { |
294 // Just look for a couple of well-known libs. | 294 // Just look for a couple of well-known libs. |
295 LibraryMirror core_lib = libraries['dart:core']; | 295 LibraryMirror core_lib = libraries['dart.core']; |
296 Expect.isTrue(core_lib is LibraryMirror); | 296 Expect.isTrue(core_lib is LibraryMirror); |
297 | 297 |
298 LibraryMirror mirror_lib = libraries['dart:mirrors']; | 298 LibraryMirror mirror_lib = libraries['dart.mirrors']; |
299 Expect.isTrue(mirror_lib is LibraryMirror); | 299 Expect.isTrue(mirror_lib is LibraryMirror); |
300 | 300 |
301 // Lookup an interface from a library and make sure it is sane. | 301 // Lookup an interface from a library and make sure it is sane. |
302 ClassMirror list_intf = core_lib.members['List']; | 302 ClassMirror list_intf = core_lib.members['List']; |
303 Expect.isTrue(list_intf is ClassMirror); | 303 Expect.isTrue(list_intf is ClassMirror); |
304 Expect.equals('List', list_intf.simpleName); | 304 Expect.equals('List', list_intf.simpleName); |
305 Expect.equals('dart:core.List', list_intf.qualifiedName); | 305 Expect.equals('dart.core.List', list_intf.qualifiedName); |
306 Expect.isFalse(list_intf.isPrivate); | 306 Expect.isFalse(list_intf.isPrivate); |
307 Expect.equals('Object', list_intf.superclass.simpleName); | 307 Expect.equals('Object', list_intf.superclass.simpleName); |
308 Expect.equals('dart:core', list_intf.owner.simpleName); | 308 Expect.equals('dart.core', list_intf.owner.simpleName); |
309 Expect.isTrue(list_intf.isClass); | 309 Expect.isTrue(list_intf.isClass); |
310 Expect.equals('Collection', list_intf.superinterfaces[0].simpleName); | 310 Expect.equals('Collection', list_intf.superinterfaces[0].simpleName); |
311 Expect.equals("ClassMirror on 'List'", list_intf.toString()); | 311 Expect.equals("ClassMirror on 'List'", list_intf.toString()); |
312 | 312 |
313 // Lookup a class from a library and make sure it is sane. | 313 // Lookup a class from a library and make sure it is sane. |
314 ClassMirror oom_cls = core_lib.members['OutOfMemoryError']; | 314 ClassMirror oom_cls = core_lib.members['OutOfMemoryError']; |
315 Expect.isTrue(oom_cls is ClassMirror); | 315 Expect.isTrue(oom_cls is ClassMirror); |
316 Expect.equals('OutOfMemoryError', oom_cls.simpleName); | 316 Expect.equals('OutOfMemoryError', oom_cls.simpleName); |
317 Expect.equals('dart:core.OutOfMemoryError', oom_cls.qualifiedName); | 317 Expect.equals('dart.core.OutOfMemoryError', oom_cls.qualifiedName); |
318 Expect.isFalse(oom_cls.isPrivate); | 318 Expect.isFalse(oom_cls.isPrivate); |
319 Expect.equals('Object', oom_cls.superclass.simpleName); | 319 Expect.equals('Object', oom_cls.superclass.simpleName); |
320 Expect.isTrue(oom_cls.defaultFactory == null); | 320 Expect.isTrue(oom_cls.defaultFactory == null); |
321 Expect.equals('dart:core', oom_cls.owner.simpleName); | 321 Expect.equals('dart.core', oom_cls.owner.simpleName); |
322 Expect.isTrue(oom_cls.isClass); | 322 Expect.isTrue(oom_cls.isClass); |
323 Expect.equals('Error', oom_cls.superinterfaces[0].simpleName); | 323 Expect.equals('Error', oom_cls.superinterfaces[0].simpleName); |
324 Expect.equals("ClassMirror on 'OutOfMemoryError'", | 324 Expect.equals("ClassMirror on 'OutOfMemoryError'", |
325 oom_cls.toString()); | 325 oom_cls.toString()); |
326 testDone('testLibrariesMap'); | 326 testDone('testLibrariesMap'); |
327 } | 327 } |
328 | 328 |
329 void testMirrorSystem(MirrorSystem mirrors) { | 329 void testMirrorSystem(MirrorSystem mirrors) { |
330 Expect.isTrue(mirrors.isolate.debugName.contains('main')); | 330 Expect.isTrue(mirrors.isolate.debugName.contains('main')); |
331 testRootLibraryMirror(mirrors.isolate.rootLibrary); | 331 testRootLibraryMirror(mirrors.isolate.rootLibrary); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // Test that an isolate can reflect on itself. | 521 // Test that an isolate can reflect on itself. |
522 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); | 522 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); |
523 | 523 |
524 testIntegerInstanceMirror(reflect(1001)); | 524 testIntegerInstanceMirror(reflect(1001)); |
525 testStringInstanceMirror(reflect('This\nis\na\nString')); | 525 testStringInstanceMirror(reflect('This\nis\na\nString')); |
526 testBoolInstanceMirror(reflect(true)); | 526 testBoolInstanceMirror(reflect(true)); |
527 testNullInstanceMirror(reflect(null)); | 527 testNullInstanceMirror(reflect(null)); |
528 testCustomInstanceMirror(reflect(new MyClass(17))); | 528 testCustomInstanceMirror(reflect(new MyClass(17))); |
529 testMirrorErrors(currentMirrorSystem()); | 529 testMirrorErrors(currentMirrorSystem()); |
530 } | 530 } |
OLD | NEW |