Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library test.null_test; | |
| 6 | |
| 7 import 'dart:mirrors'; | |
| 8 | |
| 9 import 'package:expect/expect.dart'; | |
| 10 | |
| 11 main() { | |
| 12 InstanceMirror nullMirror = reflect(null); | |
| 13 Expect.isTrue(nullMirror.getField(const Symbol('hashCode')).reflectee is int); | |
| 14 Expect.equals('Null', | |
| 15 nullMirror.getField(const Symbol('runtimeType')).reflectee | |
| 16 .toString()); | |
| 17 Expect.isTrue(nullMirror.invoke(const Symbol('=='), [null]).reflectee); | |
| 18 Expect.isFalse(nullMirror.invoke(const Symbol('=='), [new Object()]) | |
| 19 .reflectee); | |
| 20 Expect.equals('null', | |
| 21 nullMirror.invoke(const Symbol('toString'), []).reflectee); | |
| 22 Expect.throws(() => nullMirror.invoke(const Symbol('notDefined'), []), | |
| 23 (e) => e is NoSuchMethodError, | |
| 24 'noSuchMethod'); | |
| 25 | |
| 26 ClassMirror NullMirror = nullMirror.type; | |
| 27 Expect.equals(const Symbol('Null'), NullMirror.simpleName); | |
| 28 Expect.equals(const Symbol('Object'), NullMirror.superclass.simpleName); | |
| 29 Expect.equals(null, NullMirror.superclass.superclass); | |
| 30 Expect.equals(null, NullMirror.owner); // Null belongs to no library. | |
|
ahe
2013/08/06 11:13:38
Where is this specified?
| |
| 31 } | |
| OLD | NEW |