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); |
+} |