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

Side by Side Diff: tests/language/bound_closure_equality_test.dart

Issue 16042014: Implement operator== and hashCode for bound closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
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 import "package:expect/expect.dart";
6
7 class A {
8 const A();
9 foo() => 42;
10 }
11
12 class B {
13 foo() => 42;
14 }
15
16 main() {
17 // Use an array to defeat type inferencing.
18 var array = [new A(), new A(), new B(), new B()];
19 var set = new Set.from(array.map((a) => a.foo));
kasperl 2013/05/29 19:08:56 Check the length of the set. Should be 4, right? T
ngeoffray 2013/05/30 06:45:46 Done.
20 for (int i = 0; i < array.length; i += 2) {
21 Expect.isTrue(set.contains(array[i].foo));
22 Expect.equals(array[i], array[i]);
23 Expect.equals(array[i].foo, array[i].foo);
24 Expect.equals(array[i].foo.hashCode, array[i].foo.hashCode);
25 for (int j = 0; j < array.length; j++) {
26 if (i == j) continue;
27 Expect.notEquals(array[i].foo, array[j].foo);
28 }
29 }
30
31 // Try with dart2js intercepted types.
32 array = ['foo', 'bar', [], [], const []];
33 set = new Set.from(array.map((a) => a.indexOf));
34 for (int i = 0; i < array.length; i += 2) {
35 Expect.isTrue(set.contains(array[i].indexOf));
36 Expect.equals(array[i], array[i]);
37 Expect.equals(array[i].indexOf, array[i].indexOf);
38 Expect.equals(array[i].indexOf.hashCode, array[i].indexOf.hashCode);
39 for (int j = 0; j < array.length; j++) {
40 if (i == j) continue;
41 Expect.notEquals(array[i].indexOf, array[j].indexOf);
42 }
43 }
44
45 array = [const A(), const A()];
46 set = new Set.from(array.map((a) => a.foo));
47 Expect.isTrue(set.contains(array[0].foo));
48 Expect.equals(array[0].foo, array[0].foo);
49 Expect.equals(array[0].foo.hashCode, array[0].foo.hashCode);
50 Expect.equals(array[0].foo, array[1].foo);
51 Expect.equals(array[0].foo.hashCode, array[1].foo.hashCode);
52
53 array = [const [], const []];
54 set = new Set.from(array.map((a) => a.indexOf));
55 Expect.isTrue(set.contains(array[0].indexOf));
56 Expect.equals(array[0].indexOf, array[0].indexOf);
57 Expect.equals(array[0].indexOf.hashCode, array[0].indexOf.hashCode);
58 Expect.equals(array[0].indexOf, array[1].indexOf);
59 Expect.equals(array[0].indexOf.hashCode, array[1].indexOf.hashCode);
60 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698