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 #library('isolate_mirror_local_test'); | 8 #library('isolate_mirror_local_test'); |
9 | 9 |
10 #import('dart:isolate'); | 10 #import('dart:isolate'); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 int method(int arg) { | 361 int method(int arg) { |
362 return arg + value; | 362 return arg + value; |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 void testCustomInstanceMirror(InstanceMirror mirror) { | 366 void testCustomInstanceMirror(InstanceMirror mirror) { |
367 Expect.isTrue(mirror.hasReflectee); | 367 Expect.isTrue(mirror.hasReflectee); |
368 bool saw_exception = false; | 368 bool saw_exception = false; |
369 try { | 369 try { |
370 mirror.reflectee; | 370 mirror.reflectee; |
371 } catch (MirrorException me) { | 371 } on MirrorException catch (me) { |
372 saw_exception = true; | 372 saw_exception = true; |
373 } | 373 } |
374 Expect.isFalse(saw_exception); | 374 Expect.isFalse(saw_exception); |
375 Expect.equals("InstanceMirror on instance of 'MyClass'", mirror.toString()); | 375 Expect.equals("InstanceMirror on instance of 'MyClass'", mirror.toString()); |
376 | 376 |
377 ClassMirror cls = mirror.type; | 377 ClassMirror cls = mirror.type; |
378 Expect.isTrue(cls is ClassMirror); | 378 Expect.isTrue(cls is ClassMirror); |
379 Expect.equals('MyClass', cls.simpleName); | 379 Expect.equals('MyClass', cls.simpleName); |
380 Expect.equals('MySuperClass', cls.superclass.simpleName); | 380 Expect.equals('MySuperClass', cls.superclass.simpleName); |
381 Expect.isTrue(cls.defaultFactory === null); | 381 Expect.isTrue(cls.defaultFactory === null); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // Test that an isolate can reflect on itself. | 488 // Test that an isolate can reflect on itself. |
489 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); | 489 mirrorSystemOf(exit_port.toSendPort()).then(testMirrorSystem); |
490 | 490 |
491 testIntegerInstanceMirror(reflect(1001)); | 491 testIntegerInstanceMirror(reflect(1001)); |
492 testStringInstanceMirror(reflect('This\nis\na\nString')); | 492 testStringInstanceMirror(reflect('This\nis\na\nString')); |
493 testBoolInstanceMirror(reflect(true)); | 493 testBoolInstanceMirror(reflect(true)); |
494 testNullInstanceMirror(reflect(null)); | 494 testNullInstanceMirror(reflect(null)); |
495 testCustomInstanceMirror(reflect(new MyClass(17))); | 495 testCustomInstanceMirror(reflect(new MyClass(17))); |
496 testMirrorErrors(currentMirrorSystem()); | 496 testMirrorErrors(currentMirrorSystem()); |
497 } | 497 } |
OLD | NEW |