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

Unified Diff: test/codegen/lib/mirrors/null_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 | « test/codegen/lib/mirrors/null2_test.dart ('k') | test/codegen/lib/mirrors/operator_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/mirrors/null_test.dart
diff --git a/test/codegen/lib/mirrors/null_test.dart b/test/codegen/lib/mirrors/null_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2b6407b2a20fc307ad1b6ec6cba11cdb5b1add57
--- /dev/null
+++ b/test/codegen/lib/mirrors/null_test.dart
@@ -0,0 +1,46 @@
+// 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(#hashCode).reflectee is int);
+ Expect.equals(null.hashCode,
+ nullMirror.getField(#hashCode).reflectee);
+ Expect.equals('Null',
+ nullMirror.getField(#runtimeType).reflectee
+ .toString());
+ Expect.isTrue(nullMirror.invoke(#==, [null]).reflectee);
+ Expect.isFalse(nullMirror.invoke(#==, [new Object()])
+ .reflectee);
+ Expect.equals('null',
+ nullMirror.invoke(#toString, []).reflectee);
+ Expect.throws(() => nullMirror.invoke(#notDefined, []),
+ (e) => e is NoSuchMethodError,
+ 'noSuchMethod');
+
+ ClassMirror NullMirror = nullMirror.type;
+ Expect.equals(reflectClass(Null), NullMirror);
+ Expect.equals(#Null, NullMirror.simpleName);
+ Expect.equals(#Object, NullMirror.superclass.simpleName);
+ Expect.equals(null, NullMirror.superclass.superclass);
+ Expect.listEquals([], NullMirror.superinterfaces);
+ Map<Uri, LibraryMirror> libraries = currentMirrorSystem().libraries;
+ LibraryMirror coreLibrary = libraries[Uri.parse('dart:core')];
+ if (coreLibrary == null) {
+ // In minified mode we don't preserve the URIs.
+ coreLibrary = libraries.values
+ .firstWhere((LibraryMirror lm) => lm.simpleName == #dart.core);
+ Uri uri = coreLibrary.uri;
+ Expect.equals("https", uri.scheme);
+ Expect.equals("dartlang.org", uri.host);
+ Expect.equals("/dart2js-stripped-uri", uri.path);
+ }
+ Expect.equals(coreLibrary, NullMirror.owner);
+}
« no previous file with comments | « test/codegen/lib/mirrors/null2_test.dart ('k') | test/codegen/lib/mirrors/operator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698