| 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; |
| 11 | 11 |
| 12 import "package:expect/expect.dart"; | 12 import "package:expect/expect.dart"; |
| 13 import 'dart:async'; | 13 import 'dart:async'; |
| 14 import 'dart:isolate'; | 14 import 'dart:isolate'; |
| 15 import 'dart:mirrors'; | 15 import 'dart:mirrors'; |
| 16 import 'dart:uri'; |
| 16 | 17 |
| 17 ReceivePort exit_port; | 18 ReceivePort exit_port; |
| 18 Set expectedTests; | 19 Set expectedTests; |
| 19 | 20 |
| 20 void testDone(String test) { | 21 void testDone(String test) { |
| 21 if (!expectedTests.contains(test)) { | 22 if (!expectedTests.contains(test)) { |
| 22 throw "Unexpected test name '$test'"; | 23 throw "Unexpected test name '$test'"; |
| 23 } | 24 } |
| 24 expectedTests.remove(test); | 25 expectedTests.remove(test); |
| 25 if (expectedTests.isEmpty) { | 26 if (expectedTests.isEmpty) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 294 |
| 294 // Test function type mirrors. | 295 // Test function type mirrors. |
| 295 var func_cls_mirror = typedef_mirror.referent; | 296 var func_cls_mirror = typedef_mirror.referent; |
| 296 Expect.isTrue(func_cls_mirror is FunctionTypeMirror); | 297 Expect.isTrue(func_cls_mirror is FunctionTypeMirror); |
| 297 // Expect.equals('void (dart.core.String)', func_cls_mirror.simpleName); | 298 // Expect.equals('void (dart.core.String)', func_cls_mirror.simpleName); |
| 298 Expect.equals(const Symbol('void'), func_cls_mirror.returnType.simpleName); | 299 Expect.equals(const Symbol('void'), func_cls_mirror.returnType.simpleName); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void testLibrariesMap(Map libraries) { | 302 void testLibrariesMap(Map libraries) { |
| 302 // Just look for a couple of well-known libs. | 303 // Just look for a couple of well-known libs. |
| 303 LibraryMirror core_lib = libraries[const Symbol('dart.core')]; | 304 LibraryMirror core_lib = libraries[Uri.parse('dart:core')]; |
| 304 Expect.isTrue(core_lib is LibraryMirror); | 305 Expect.isTrue(core_lib is LibraryMirror); |
| 305 | 306 |
| 306 LibraryMirror mirror_lib = libraries[const Symbol('dart.mirrors')]; | 307 LibraryMirror mirror_lib = libraries[Uri.parse('dart:mirrors')]; |
| 307 Expect.isTrue(mirror_lib is LibraryMirror); | 308 Expect.isTrue(mirror_lib is LibraryMirror); |
| 308 | 309 |
| 309 // Lookup an interface from a library and make sure it is sane. | 310 // Lookup an interface from a library and make sure it is sane. |
| 310 ClassMirror list_intf = core_lib.members[const Symbol('List')]; | 311 ClassMirror list_intf = core_lib.members[const Symbol('List')]; |
| 311 Expect.isTrue(list_intf is ClassMirror); | 312 Expect.isTrue(list_intf is ClassMirror); |
| 312 Expect.equals(const Symbol('List'), list_intf.simpleName); | 313 Expect.equals(const Symbol('List'), list_intf.simpleName); |
| 313 Expect.equals(const Symbol('dart.core.List'), list_intf.qualifiedName); | 314 Expect.equals(const Symbol('dart.core.List'), list_intf.qualifiedName); |
| 314 Expect.isFalse(list_intf.isPrivate); | 315 Expect.isFalse(list_intf.isPrivate); |
| 315 Expect.equals(const Symbol('Object'), list_intf.superclass.simpleName); | 316 Expect.equals(const Symbol('Object'), list_intf.superclass.simpleName); |
| 316 Expect.equals(const Symbol('dart.core'), list_intf.owner.simpleName); | 317 Expect.equals(const Symbol('dart.core'), list_intf.owner.simpleName); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // Test that an isolate can reflect on itself. | 536 // Test that an isolate can reflect on itself. |
| 536 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); | 537 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); |
| 537 | 538 |
| 538 testIntegerInstanceMirror(reflect(1001)); | 539 testIntegerInstanceMirror(reflect(1001)); |
| 539 testStringInstanceMirror(reflect('This\nis\na\nString')); | 540 testStringInstanceMirror(reflect('This\nis\na\nString')); |
| 540 testBoolInstanceMirror(reflect(true)); | 541 testBoolInstanceMirror(reflect(true)); |
| 541 testNullInstanceMirror(reflect(null)); | 542 testNullInstanceMirror(reflect(null)); |
| 542 testCustomInstanceMirror(reflect(new MyClass(17))); | 543 testCustomInstanceMirror(reflect(new MyClass(17))); |
| 543 testMirrorErrors(currentMirrorSystem()); | 544 testMirrorErrors(currentMirrorSystem()); |
| 544 } | 545 } |
| OLD | NEW |