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

Side by Side Diff: tests/lib/mirrors/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, expand equality coverage Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/libraries_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.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 checkEquality(List<Map> equivalenceClasses) {
15 for (var equivalenceClass in equivalenceClasses) {
16 equivalenceClass.forEach((name, member) {
17 equivalenceClass.forEach((otherName, otherMember) {
18 // Reflexivity, symmetry and transitivity.
19 Expect.equals(member,
20 otherMember,
21 "$name == $otherName");
22 Expect.equals(member.hashCode,
23 otherMember.hashCode,
24 "$name.hashCode == $otherName.hashCode");
25 });
26 for (var otherEquivalenceClass in equivalenceClasses) {
27 if (otherEquivalenceClass == equivalenceClass) continue;
28 otherEquivalenceClass.forEach((otherName, otherMember) {
29 Expect.notEquals(member,
30 otherMember,
31 "$name != $otherName"); // Exclusion.
32 // Hash codes may or may not be equal.
33 });
34 }
35 });
36 }
37 }
38
39 void subroutine() {
40 }
41
42 main() {
43 LibraryMirror thisLibrary =
44 currentMirrorSystem()
45 .findLibrary(const Symbol('test.class_equality_test'))
46 .single;
47
48 Object o1 = new Object();
49 Object o2 = new Object();
50
51 checkEquality([
52 {'reflect(o1)' : reflect(o1),
53 'reflect(o1), again' : reflect(o1)},
54
55 {'reflect(o2)' : reflect(o2),
56 'reflect(o2), again' : reflect(o2)},
57
58 {'reflect(3+4)' : reflect(3+4),
59 'reflect(6+1)' : reflect(6+1)},
60
61 {'currentMirrorSystem().voidType' : currentMirrorSystem().voidType,
62 'thisLibrary.functions[#subroutine].returnType' :
63 thisLibrary.functions[const Symbol('subroutine')].returnType},
64
65 {'currentMirrorSystem().dynamicType' : currentMirrorSystem().dynamicType,
66 'thisLibrary.functions[#main].returnType' :
67 thisLibrary.functions[const Symbol('main')].returnType},
68
69 {'reflectClass(A)' : reflectClass(A),
70 'thisLibrary.classes[#A]' : thisLibrary.classes[const Symbol('A')],
71 'reflect(new A<int>()).type.originalDeclaration' :
72 reflect(new A<int>()).type.originalDeclaration},
73
74 {'reflectClass(B).superclass' : reflectClass(B).superclass,
75 'reflect(new A<int>()).type' : reflect(new A<int>()).type},
76
77 {'reflectClass(B)' : reflectClass(B),
78 'thisLibrary.classes[#B]' : thisLibrary.classes[const Symbol('B')],
79 'reflect(new B()).type' : reflect(new B()).type},
80
81 {'thisLibrary' : thisLibrary,
82 'reflectClass(A).owner' : reflectClass(A).owner,
83 'reflectClass(B).owner' : reflectClass(B).owner,
84 'reflect(new A()).type.owner' : reflect(new A()).type.owner,
85 'reflect(new A()).type.owner' : reflect(new A()).type.owner},
86 ]);
87 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/libraries_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698