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

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

Issue 2985243002: Migrate block 44. (Closed)
Patch Set: Created 3 years, 4 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
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));
20 Expect.equals(array.length, set.length);
21 set.addAll(array.map((a) => a.foo));
22 Expect.equals(array.length, set.length);
23
24 for (int i = 0; i < array.length; i += 2) {
25 Expect.isTrue(set.contains(array[i].foo));
26 Expect.equals(array[i], array[i]);
27 Expect.equals(array[i].foo, array[i].foo);
28 Expect.equals(array[i].foo.hashCode, array[i].foo.hashCode);
29 for (int j = 0; j < array.length; j++) {
30 if (i == j) continue;
31 Expect.notEquals(array[i].foo, array[j].foo);
32 }
33 }
34
35 // Try with dart2js intercepted types.
36 array = ['foo', 'bar', [], [], const []];
37 set = new Set.from(array.map((a) => a.indexOf));
38 Expect.equals(array.length, set.length);
39 set.addAll(array.map((a) => a.indexOf));
40 Expect.equals(array.length, set.length);
41
42 for (int i = 0; i < array.length; i += 2) {
43 Expect.isTrue(set.contains(array[i].indexOf));
44 Expect.equals(array[i], array[i]);
45 Expect.equals(array[i].indexOf, array[i].indexOf);
46 Expect.equals(array[i].indexOf.hashCode, array[i].indexOf.hashCode);
47 for (int j = 0; j < array.length; j++) {
48 if (i == j) continue;
49 Expect.notEquals(array[i].indexOf, array[j].indexOf);
50 }
51 }
52
53 array = [const A(), const A()];
54 set = new Set.from(array.map((a) => a.foo));
55 Expect.equals(1, set.length);
56 set.addAll(array.map((a) => a.foo));
57 Expect.equals(1, set.length);
58
59 Expect.isTrue(set.contains(array[0].foo));
60 Expect.equals(array[0].foo, array[0].foo);
61 Expect.equals(array[0].foo.hashCode, array[0].foo.hashCode);
62 Expect.equals(array[0].foo, array[1].foo);
63 Expect.equals(array[0].foo.hashCode, array[1].foo.hashCode);
64
65 array = [const [], const []];
66 set = new Set.from(array.map((a) => a.indexOf));
67 Expect.equals(1, set.length);
68 set.addAll(array.map((a) => a.indexOf));
69 Expect.equals(1, set.length);
70
71 Expect.isTrue(set.contains(array[0].indexOf));
72 Expect.equals(array[0].indexOf, array[0].indexOf);
73 Expect.equals(array[0].indexOf.hashCode, array[0].indexOf.hashCode);
74 Expect.equals(array[0].indexOf, array[1].indexOf);
75 Expect.equals(array[0].indexOf.hashCode, array[1].indexOf.hashCode);
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698