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

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() {
kasperl 2013/05/29 13:24:08 We probably also need a test that shows the two no
ngeoffray 2013/05/29 15:33:19 Done.
17 // Use an array to defeat type inferencing.
kasperl 2013/05/29 13:24:08 Throw them in a map (or set) too and make sure you
ngeoffray 2013/05/29 15:33:19 Done.
18 var array = [new A(), new A(), new B(), new B()];
19 for (int i = 0; i < array.length; i += 2) {
20 Expect.equals(array[i], array[i]);
21 Expect.equals(array[i].foo, array[i].foo);
22 Expect.equals(array[i].foo.hashCode, array[i].foo.hashCode);
23 for (int j = 0; j < array.length; j++) {
24 if (i == j) continue;
25 Expect.notEquals(array[i].foo, array[j].foo);
26 }
27 }
28
29 // Try with dart2js intercepted types.
30 array = ['foo', 'bar', [], [], const []];
31 for (int i = 0; i < array.length; i += 2) {
32 Expect.equals(array[i], array[i]);
33 Expect.equals(array[i].indexOf, array[i].indexOf);
34 Expect.equals(array[i].indexOf.hashCode, array[i].indexOf.hashCode);
35 for (int j = 0; j < array.length; j++) {
36 if (i == j) continue;
37 Expect.notEquals(array[i].indexOf, array[j].indexOf);
38 }
39 }
40
41 array = [const A(), const A()];
42 Expect.equals(array[0].foo, array[0].foo);
43 Expect.equals(array[0].foo.hashCode, array[0].foo.hashCode);
44 Expect.equals(array[0].foo, array[1].foo);
45 Expect.equals(array[0].foo.hashCode, array[1].foo.hashCode);
46
47 array = [const [], const []];
48 Expect.equals(array[0].indexOf, array[0].indexOf);
49 Expect.equals(array[0].indexOf.hashCode, array[0].indexOf.hashCode);
50 Expect.equals(array[0].indexOf, array[1].indexOf);
51 Expect.equals(array[0].indexOf.hashCode, array[1].indexOf.hashCode);
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698