OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class FixedHashCode { | 7 class FixedHashCode { |
8 final int _hashCode; | 8 final int _hashCode; |
9 const FixedHashCode(this._hashCode); | 9 const FixedHashCode(this._hashCode); |
10 int get hashCode { return _hashCode; } | 10 int get hashCode { |
| 11 return _hashCode; |
| 12 } |
11 } | 13 } |
12 | 14 |
13 class SetIteratorTest { | 15 class SetIteratorTest { |
14 static testMain() { | 16 static testMain() { |
15 testSmallSet(); | 17 testSmallSet(); |
16 testLargeSet(); | 18 testLargeSet(); |
17 testEmptySet(); | 19 testEmptySet(); |
18 testSetWithDeletedEntries(); | 20 testSetWithDeletedEntries(); |
19 testBug5116829(); | 21 testBug5116829(); |
20 testDifferentSizes(); | 22 testDifferentSizes(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 Iterator<int> it = set.iterator; | 75 Iterator<int> it = set.iterator; |
74 Expect.isFalse(it.moveNext()); | 76 Expect.isFalse(it.moveNext()); |
75 it = set.iterator; | 77 it = set.iterator; |
76 sum(0, it); | 78 sum(0, it); |
77 Expect.isFalse(it.moveNext()); | 79 Expect.isFalse(it.moveNext()); |
78 Expect.isNull(it.current); | 80 Expect.isNull(it.current); |
79 | 81 |
80 int count = 0; | 82 int count = 0; |
81 for (int i = 0; i < 100; i++) { | 83 for (int i = 0; i < 100; i++) { |
82 set.add(i); | 84 set.add(i); |
83 if (i % 2 == 0) set.remove(i); | 85 if (i % 2 == 0) |
84 else count += i; | 86 set.remove(i); |
| 87 else |
| 88 count += i; |
85 } | 89 } |
86 it = set.iterator; | 90 it = set.iterator; |
87 sum(count, it); | 91 sum(count, it); |
88 Expect.isFalse(it.moveNext()); | 92 Expect.isFalse(it.moveNext()); |
89 Expect.isNull(it.current); | 93 Expect.isNull(it.current); |
90 } | 94 } |
91 | 95 |
92 static void testBug5116829() { | 96 static void testBug5116829() { |
93 // During iteration we skipped slot 0 of the hashset's key list. "A" was | 97 // During iteration we skipped slot 0 of the hashset's key list. "A" was |
94 // hashed to slot 0 and therefore triggered the bug. | 98 // hashed to slot 0 and therefore triggered the bug. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 Expect.equals(true, identical(x, element)); | 137 Expect.equals(true, identical(x, element)); |
134 } | 138 } |
135 Expect.equals(true, foundIt); | 139 Expect.equals(true, foundIt); |
136 } | 140 } |
137 } | 141 } |
138 } | 142 } |
139 | 143 |
140 main() { | 144 main() { |
141 SetIteratorTest.testMain(); | 145 SetIteratorTest.testMain(); |
142 } | 146 } |
OLD | NEW |