| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 Expect.equals('global_var type(int) toplevel static', | 263 Expect.equals('global_var type(int) toplevel static', |
| 264 buildVariableString(variable)); | 264 buildVariableString(variable)); |
| 265 | 265 |
| 266 variable = lib_mirror.members['final_global_var']; | 266 variable = lib_mirror.members['final_global_var']; |
| 267 Expect.isTrue(variable is VariableMirror); | 267 Expect.isTrue(variable is VariableMirror); |
| 268 Expect.equals('final_global_var type(int) toplevel static final', | 268 Expect.equals('final_global_var type(int) toplevel static final', |
| 269 buildVariableString(variable)); | 269 buildVariableString(variable)); |
| 270 | 270 |
| 271 variable = cls_mirror.members['value']; | 271 variable = cls_mirror.members['value']; |
| 272 Expect.isTrue(variable is VariableMirror); | 272 Expect.isTrue(variable is VariableMirror); |
| 273 Expect.equals('value type(Dynamic) final', buildVariableString(variable)); | 273 Expect.equals('value type(dynamic) final', buildVariableString(variable)); |
| 274 | 274 |
| 275 // Test type variable mirrors. | 275 // Test type variable mirrors. |
| 276 var type_var = generic_cls_mirror.members['method'].returnType; | 276 var type_var = generic_cls_mirror.members['method'].returnType; |
| 277 Expect.isTrue(type_var is TypeVariableMirror); | 277 Expect.isTrue(type_var is TypeVariableMirror); |
| 278 Expect.equals('GenericClass', type_var.owner.simpleName); | 278 Expect.equals('GenericClass', type_var.owner.simpleName); |
| 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); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 332 testLibrariesMap(mirrors.libraries); | 332 testLibrariesMap(mirrors.libraries); |
| 333 Expect.equals('void', mirrors.voidType.simpleName); | 333 Expect.equals('void', mirrors.voidType.simpleName); |
| 334 Expect.equals('Dynamic', mirrors.dynamicType.simpleName); | 334 Expect.equals('dynamic', mirrors.dynamicType.simpleName); |
| 335 testDone('testMirrorSystem'); | 335 testDone('testMirrorSystem'); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void testIntegerInstanceMirror(InstanceMirror mirror) { | 338 void testIntegerInstanceMirror(InstanceMirror mirror) { |
| 339 Expect.equals('int', mirror.type.simpleName); | 339 Expect.equals('int', mirror.type.simpleName); |
| 340 Expect.isTrue(mirror.hasReflectee); | 340 Expect.isTrue(mirror.hasReflectee); |
| 341 Expect.equals(1001, mirror.reflectee); | 341 Expect.equals(1001, mirror.reflectee); |
| 342 Expect.equals("InstanceMirror on <1001>", mirror.toString()); | 342 Expect.equals("InstanceMirror on <1001>", mirror.toString()); |
| 343 | 343 |
| 344 // Invoke (mirror + mirror). | 344 // Invoke (mirror + mirror). |
| (...skipping 176 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 |