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

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

Issue 23657002: Ensure class mirrors on non-generic classes always have their runtime type set. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 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
« runtime/lib/mirrors_impl.dart ('K') | « 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/class_equality_test.dart
diff --git a/tests/lib/mirrors/class_equality_test.dart b/tests/lib/mirrors/class_equality_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..63c099969bd80f7564da84531be3640615935c8a
--- /dev/null
+++ b/tests/lib/mirrors/class_equality_test.dart
@@ -0,0 +1,57 @@
+// 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.class_equality_test;
+
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+class A<T> {}
+class B extends A<int> {}
+
+main() {
+ LibraryMirror thisLibrary =
+ currentMirrorSystem()
+ .findLibrary(const Symbol('test.class_equality_test'))
+ .single;
+
+ ClassMirror A_declaration = reflectClass(A);
+ ClassMirror A_instantiated_with_int = reflectClass(B).superclass;
+ ClassMirror A_from_library = thisLibrary.classes[const Symbol('A')];
+ ClassMirror A_from_instance = reflect(new A<int>()).type;
+
+ // Test for symmetry!
+ Expect.notEquals(A_declaration, A_instantiated_with_int);
+ Expect.notEquals(A_instantiated_with_int, A_declaration);
+
+ Expect.equals(A_declaration, A_from_library);
+ Expect.equals(A_from_library, A_declaration);
+
+ Expect.notEquals(A_from_library, A_instantiated_with_int);
+ Expect.notEquals(A_instantiated_with_int, A_from_library);
+
+ Expect.equals(A_from_instance, A_instantiated_with_int);
+ Expect.equals(A_instantiated_with_int, A_from_instance);
+
+ Expect.notEquals(A_declaration, A_from_instance);
+ Expect.notEquals(A_from_instance, A_declaration);
+
+ Expect.notEquals(A_from_library, A_from_instance);
+ Expect.notEquals(A_from_instance, A_from_library);
+
+
+ ClassMirror B_declaration = reflectClass(B);
+ ClassMirror B_from_library = thisLibrary.classes[const Symbol('B')];
+ ClassMirror B_from_instance = reflect(new B()).type;
+
+ Expect.equals(B_declaration, B_from_library);
+ Expect.equals(B_from_library, B_declaration);
+
+ Expect.equals(B_from_instance, B_from_library);
+ Expect.equals(B_from_library, B_from_instance);
+
+ Expect.equals(B_declaration, B_from_instance);
+ Expect.equals(B_from_instance, B_declaration);
+}
« runtime/lib/mirrors_impl.dart ('K') | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698