OLD | NEW |
(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.class_equality_test; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 |
| 9 import 'package:expect/expect.dart'; |
| 10 |
| 11 class A<T> {} |
| 12 class B extends A<int> {} |
| 13 |
| 14 main() { |
| 15 LibraryMirror thisLibrary = |
| 16 currentMirrorSystem() |
| 17 .findLibrary(const Symbol('test.class_equality_test')) |
| 18 .single; |
| 19 |
| 20 ClassMirror A_declaration = reflectClass(A); |
| 21 ClassMirror A_instantiated_with_int = reflectClass(B).superclass; |
| 22 ClassMirror A_from_library = thisLibrary.classes[const Symbol('A')]; |
| 23 ClassMirror A_from_instance = reflect(new A<int>()).type; |
| 24 |
| 25 // Test for symmetry! |
| 26 Expect.notEquals(A_declaration, A_instantiated_with_int); |
| 27 Expect.notEquals(A_instantiated_with_int, A_declaration); |
| 28 |
| 29 Expect.equals(A_declaration, A_from_library); |
| 30 Expect.equals(A_from_library, A_declaration); |
| 31 |
| 32 Expect.notEquals(A_from_library, A_instantiated_with_int); |
| 33 Expect.notEquals(A_instantiated_with_int, A_from_library); |
| 34 |
| 35 Expect.equals(A_from_instance, A_instantiated_with_int); |
| 36 Expect.equals(A_instantiated_with_int, A_from_instance); |
| 37 |
| 38 Expect.notEquals(A_declaration, A_from_instance); |
| 39 Expect.notEquals(A_from_instance, A_declaration); |
| 40 |
| 41 Expect.notEquals(A_from_library, A_from_instance); |
| 42 Expect.notEquals(A_from_instance, A_from_library); |
| 43 |
| 44 |
| 45 ClassMirror B_declaration = reflectClass(B); |
| 46 ClassMirror B_from_library = thisLibrary.classes[const Symbol('B')]; |
| 47 ClassMirror B_from_instance = reflect(new B()).type; |
| 48 |
| 49 Expect.equals(B_declaration, B_from_library); |
| 50 Expect.equals(B_from_library, B_declaration); |
| 51 |
| 52 Expect.equals(B_from_instance, B_from_library); |
| 53 Expect.equals(B_from_library, B_from_instance); |
| 54 |
| 55 Expect.equals(B_declaration, B_from_instance); |
| 56 Expect.equals(B_from_instance, B_declaration); |
| 57 } |
OLD | NEW |