ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/MapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/MapTest.java (file contents):
Revision 1.2 by jsr166, Mon Jan 8 03:56:32 2018 UTC vs.
Revision 1.4 by jsr166, Tue Dec 18 03:54:01 2018 UTC

# Line 139 | Line 139 | public class MapTest extends JSR166TestC
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   //     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines