8bdc9b5696
BUG=http://dartbug.com/12364 R=asiva@google.com, regis@google.com Review URL: https://codereview.chromium.org//22819005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26205 260f80e4-7a28-3924-810f-c04153c831b5
37 lines
1.5 KiB
Dart
37 lines
1.5 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library test.null_test;
|
|
|
|
import 'dart:mirrors';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
main() {
|
|
InstanceMirror nullMirror = reflect(null);
|
|
Expect.isTrue(nullMirror.getField(const Symbol('hashCode')).reflectee is int);
|
|
Expect.equals(null.hashCode,
|
|
nullMirror.getField(const Symbol('hashCode')).reflectee);
|
|
Expect.equals('Null',
|
|
nullMirror.getField(const Symbol('runtimeType')).reflectee
|
|
.toString());
|
|
Expect.isTrue(nullMirror.invoke(const Symbol('=='), [null]).reflectee);
|
|
Expect.isFalse(nullMirror.invoke(const Symbol('=='), [new Object()])
|
|
.reflectee);
|
|
Expect.equals('null',
|
|
nullMirror.invoke(const Symbol('toString'), []).reflectee);
|
|
Expect.throws(() => nullMirror.invoke(const Symbol('notDefined'), []),
|
|
(e) => e is NoSuchMethodError,
|
|
'noSuchMethod');
|
|
|
|
ClassMirror NullMirror = nullMirror.type;
|
|
Expect.equals(reflectClass(Null), NullMirror);
|
|
Expect.equals(const Symbol('Null'), NullMirror.simpleName);
|
|
Expect.equals(const Symbol('Object'), NullMirror.superclass.simpleName);
|
|
Expect.equals(null, NullMirror.superclass.superclass);
|
|
Expect.listEquals([], NullMirror.superinterfaces);
|
|
Expect.equals(currentMirrorSystem().libraries[Uri.parse('dart:core')],
|
|
NullMirror.owner);
|
|
}
|