| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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')); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } on MirrorException catch (me) { | 416 } on MirrorException catch (me) { |
| 417 saw_exception = true; | 417 saw_exception = true; |
| 418 } | 418 } |
| 419 Expect.isFalse(saw_exception); | 419 Expect.isFalse(saw_exception); |
| 420 Expect.equals("InstanceMirror on instance of 'MyClass'", mirror.toString()); | 420 Expect.equals("InstanceMirror on instance of 'MyClass'", mirror.toString()); |
| 421 | 421 |
| 422 ClassMirror cls = mirror.type; | 422 ClassMirror cls = mirror.type; |
| 423 Expect.isTrue(cls is ClassMirror); | 423 Expect.isTrue(cls is ClassMirror); |
| 424 Expect.equals('MyClass', cls.simpleName); | 424 Expect.equals('MyClass', cls.simpleName); |
| 425 Expect.equals('MySuperClass', cls.superclass.simpleName); | 425 Expect.equals('MySuperClass', cls.superclass.simpleName); |
| 426 Expect.isTrue(cls.defaultFactory === null); | 426 Expect.isTrue(cls.defaultFactory == null); |
| 427 Expect.equals('isolate_mirror_local_test', cls.owner.simpleName); | 427 Expect.equals('isolate_mirror_local_test', cls.owner.simpleName); |
| 428 Expect.isTrue(cls.isClass); | 428 Expect.isTrue(cls.isClass); |
| 429 Expect.equals('MyInterface', cls.superinterfaces[0].simpleName); | 429 Expect.equals('MyInterface', cls.superinterfaces[0].simpleName); |
| 430 Expect.equals("ClassMirror on 'MyClass'", | 430 Expect.equals("ClassMirror on 'MyClass'", |
| 431 cls.toString()); | 431 cls.toString()); |
| 432 | 432 |
| 433 // Invoke mirror.method(1000). | 433 // Invoke mirror.method(1000). |
| 434 mirror.invoke('method', [ 1000 ]).then( | 434 mirror.invoke('method', [ 1000 ]).then( |
| 435 (InstanceMirror retval) { | 435 (InstanceMirror retval) { |
| 436 Expect.equals('int', retval.type.simpleName); | 436 Expect.equals('int', retval.type.simpleName); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // Test that an isolate can reflect on itself. | 533 // Test that an isolate can reflect on itself. |
| 534 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); | 534 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); |
| 535 | 535 |
| 536 testIntegerInstanceMirror(reflect(1001)); | 536 testIntegerInstanceMirror(reflect(1001)); |
| 537 testStringInstanceMirror(reflect('This\nis\na\nString')); | 537 testStringInstanceMirror(reflect('This\nis\na\nString')); |
| 538 testBoolInstanceMirror(reflect(true)); | 538 testBoolInstanceMirror(reflect(true)); |
| 539 testNullInstanceMirror(reflect(null)); | 539 testNullInstanceMirror(reflect(null)); |
| 540 testCustomInstanceMirror(reflect(new MyClass(17))); | 540 testCustomInstanceMirror(reflect(new MyClass(17))); |
| 541 testMirrorErrors(currentMirrorSystem()); | 541 testMirrorErrors(currentMirrorSystem()); |
| 542 } | 542 } |
| OLD | NEW |