Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: tests/lib/mirrors/null_test.dart

Issue 21277002: Add tests for reflecting on null and Null. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/null_test.dart
===================================================================
--- tests/lib/mirrors/null_test.dart (revision 0)
+++ tests/lib/mirrors/null_test.dart (revision 0)
@@ -0,0 +1,31 @@
+// 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',
+ 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(const Symbol('Null'), NullMirror.simpleName);
+ Expect.equals(const Symbol('Object'), NullMirror.superclass.simpleName);
+ Expect.equals(null, NullMirror.superclass.superclass);
+ Expect.equals(null, NullMirror.owner); // Null belongs to no library.
ahe 2013/08/06 11:13:38 Where is this specified?
+}
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698