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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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(#hashCode).reflectee is int);
14 Expect.equals(null.hashCode,
15 nullMirror.getField(#hashCode).reflectee);
16 Expect.equals('Null',
17 nullMirror.getField(#runtimeType).reflectee
18 .toString());
19 Expect.isTrue(nullMirror.invoke(#==, [null]).reflectee);
20 Expect.isFalse(nullMirror.invoke(#==, [new Object()])
21 .reflectee);
22 Expect.equals('null',
23 nullMirror.invoke(#toString, []).reflectee);
24 Expect.throws(() => nullMirror.invoke(#notDefined, []),
25 (e) => e is NoSuchMethodError,
26 'noSuchMethod');
27
28 ClassMirror NullMirror = nullMirror.type;
29 Expect.equals(reflectClass(Null), NullMirror);
30 Expect.equals(#Null, NullMirror.simpleName);
31 Expect.equals(#Object, NullMirror.superclass.simpleName);
32 Expect.equals(null, NullMirror.superclass.superclass);
33 Expect.listEquals([], NullMirror.superinterfaces);
34 Map<Uri, LibraryMirror> libraries = currentMirrorSystem().libraries;
35 LibraryMirror coreLibrary = libraries[Uri.parse('dart:core')];
36 if (coreLibrary == null) {
37 // In minified mode we don't preserve the URIs.
38 coreLibrary = libraries.values
39 .firstWhere((LibraryMirror lm) => lm.simpleName == #dart.core);
40 Uri uri = coreLibrary.uri;
41 Expect.equals("https", uri.scheme);
42 Expect.equals("dartlang.org", uri.host);
43 Expect.equals("/dart2js-stripped-uri", uri.path);
44 }
45 Expect.equals(coreLibrary, NullMirror.owner);
46 }
OLDNEW
« 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