139 |
|
assertEquals(1, m.size()); |
140 |
|
} |
141 |
|
|
142 |
+ |
/** |
143 |
+ |
* "Missing" test found while investigating JDK-8210280. |
144 |
+ |
* ant -Djsr166.tckTestClass=HashMapTest -Djsr166.methodFilter=testBug8210280 -Djsr166.runsPerTest=1000000 tck |
145 |
+ |
*/ |
146 |
+ |
public void testBug8210280() { |
147 |
+ |
final ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
148 |
+ |
final int size1 = rnd.nextInt(32); |
149 |
+ |
final int size2 = rnd.nextInt(128); |
150 |
+ |
|
151 |
+ |
final Map m1 = impl.emptyMap(); |
152 |
+ |
for (int i = 0; i < size1; i++) { |
153 |
+ |
int elt = rnd.nextInt(1024 * i, 1024 * (i + 1)); |
154 |
+ |
assertNull(m1.put(impl.makeKey(elt), impl.makeValue(elt))); |
155 |
+ |
} |
156 |
+ |
|
157 |
+ |
final Map m2 = impl.emptyMap(); |
158 |
+ |
for (int i = 0; i < size2; i++) { |
159 |
+ |
int elt = rnd.nextInt(Integer.MIN_VALUE + 1024 * i, |
160 |
+ |
Integer.MIN_VALUE + 1024 * (i + 1)); |
161 |
+ |
assertNull(m2.put(impl.makeKey(elt), impl.makeValue(-elt))); |
162 |
+ |
} |
163 |
+ |
|
164 |
+ |
final Map m1Copy = impl.emptyMap(); |
165 |
+ |
m1Copy.putAll(m1); |
166 |
+ |
|
167 |
+ |
m1.putAll(m2); |
168 |
+ |
|
169 |
+ |
for (Object elt : m2.keySet()) |
170 |
+ |
assertEquals(m2.get(elt), m1.get(elt)); |
171 |
+ |
for (Object elt : m1Copy.keySet()) |
172 |
+ |
assertSame(m1Copy.get(elt), m1.get(elt)); |
173 |
+ |
assertEquals(size1 + size2, m1.size()); |
174 |
+ |
} |
175 |
+ |
|
176 |
|
// public void testFailsIntentionallyForDebugging() { |
177 |
|
// fail(impl.klazz().getSimpleName()); |
178 |
|
// } |