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

Side by Side Diff: tests/lib/mirrors/equality_dart2js_test.dart

Issue 24008002: Merge tests for dart2js and VM using multi-tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase 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/equality_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 class BadEqualityHash {
15 int count = 0;
16 bool operator ==(other) => true;
17 int get hashCode => count++;
18 }
19
20 checkEquality(List<Map> equivalenceClasses) {
21 for (var equivalenceClass in equivalenceClasses) {
22 equivalenceClass.forEach((name, member) {
23 equivalenceClass.forEach((otherName, otherMember) {
24 // Reflexivity, symmetry and transitivity.
25 Expect.equals(member,
26 otherMember,
27 "$name == $otherName");
28 Expect.equals(member.hashCode,
29 otherMember.hashCode,
30 "$name.hashCode == $otherName.hashCode");
31 });
32 for (var otherEquivalenceClass in equivalenceClasses) {
33 if (otherEquivalenceClass == equivalenceClass) continue;
34 otherEquivalenceClass.forEach((otherName, otherMember) {
35 Expect.notEquals(member,
36 otherMember,
37 "$name != $otherName"); // Exclusion.
38 // Hash codes may or may not be equal.
39 });
40 }
41 });
42 }
43 }
44
45 void subroutine() {
46 }
47
48 main() {
49 LibraryMirror thisLibrary =
50 currentMirrorSystem()
51 .findLibrary(const Symbol('test.class_equality_test'))
52 .single;
53
54 var o1 = new Object();
55 var o2 = new Object();
56
57 var badEqualityHash1 = new BadEqualityHash();
58 var badEqualityHash2 = new BadEqualityHash();
59
60 checkEquality([
61 {'reflect(o1)' : reflect(o1),
62 'reflect(o1), again' : reflect(o1)},
63
64 {'reflect(o2)' : reflect(o2),
65 'reflect(o2), again' : reflect(o2)},
66
67 {'reflect(badEqualityHash1)' : reflect(badEqualityHash1),
68 'reflect(badEqualityHash1), again' : reflect(badEqualityHash1)},
69
70 {'reflect(badEqualityHash2)' : reflect(badEqualityHash2),
71 'reflect(badEqualityHash2), again' : reflect(badEqualityHash2)},
72
73 {'reflect(true)' : reflect(true),
74 'reflect(true), again' : reflect(true)},
75
76 {'reflect(false)' : reflect(false),
77 'reflect(false), again' : reflect(false)},
78
79 {'reflect(null)' : reflect(null),
80 'reflect(null), again' : reflect(null)},
81
82 {'reflect(3.5+4.5)' : reflect(3.5+4.5),
83 'reflect(6.5+1.5)' : reflect(6.5+1.5)},
84
85 {'reflect(3+4)' : reflect(3+4),
86 'reflect(6+1)' : reflect(6+1)},
87
88 {'reflect("foo")' : reflect("foo"),
89 'reflect("foo"), again' : reflect("foo")},
90
91 {'currentMirrorSystem().voidType' : currentMirrorSystem().voidType},
92
93 {'currentMirrorSystem().dynamicType' : currentMirrorSystem().dynamicType,
94 'thisLibrary.functions[#main].returnType' :
95 thisLibrary.functions[const Symbol('main')].returnType},
96
97 {'reflectClass(A)' : reflectClass(A),
98 'thisLibrary.classes[#A]' : thisLibrary.classes[const Symbol('A')],
99 'reflect(new A<int>()).type.originalDeclaration' :
100 reflect(new A<int>()).type.originalDeclaration},
101
102 {'reflectClass(B)' : reflectClass(B),
103 'thisLibrary.classes[#B]' : thisLibrary.classes[const Symbol('B')],
104 'reflect(new B()).type' : reflect(new B()).type},
105
106 {'thisLibrary' : thisLibrary,
107 'reflectClass(A).owner' : reflectClass(A).owner,
108 'reflectClass(B).owner' : reflectClass(B).owner,
109 'reflect(new A()).type.owner' : reflect(new A()).type.owner,
110 'reflect(new A()).type.owner' : reflect(new A()).type.owner},
111 ]);
112 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/equality_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698