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

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.56 by jsr166, Wed Aug 23 05:33:00 2017 UTC vs.
Revision 1.58 by jsr166, Mon Jan 8 03:37:59 2018 UTC

# Line 56 | Line 56 | public class ConcurrentHashMapTest exten
56          return map;
57      }
58  
59    /** Re-implement Integer.compare for old java versions */
60    static int compare(int x, int y) {
61        return (x < y) ? -1 : (x > y) ? 1 : 0;
62    }
63
59      // classes for testing Comparable fallbacks
60      static class BI implements Comparable<BI> {
61          private final int value;
62          BI(int value) { this.value = value; }
63          public int compareTo(BI other) {
64 <            return compare(value, other.value);
64 >            return Integer.compare(value, other.value);
65          }
66          public boolean equals(Object x) {
67              return (x instanceof BI) && ((BI)x).value == value;
# Line 100 | Line 95 | public class ConcurrentHashMapTest exten
95                      break;
96              }
97              if (r == 0)
98 <                r = compare(size(), other.size());
98 >                r = Integer.compare(size(), other.size());
99              return r;
100          }
101          private static final long serialVersionUID = 0;
# Line 128 | Line 123 | public class ConcurrentHashMapTest exten
123       */
124      public void testComparableFamily() {
125          int size = 500;         // makes measured test run time -> 60ms
126 <        ConcurrentHashMap<BI, Boolean> m =
132 <            new ConcurrentHashMap<BI, Boolean>();
126 >        ConcurrentHashMap<BI, Boolean> m = new ConcurrentHashMap<>();
127          for (int i = 0; i < size; i++) {
128              assertNull(m.put(new CI(i), true));
129          }
# Line 145 | Line 139 | public class ConcurrentHashMapTest exten
139       */
140      public void testGenericComparable() {
141          int size = 120;         // makes measured test run time -> 60ms
142 <        ConcurrentHashMap<Object, Boolean> m =
149 <            new ConcurrentHashMap<Object, Boolean>();
142 >        ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
143          for (int i = 0; i < size; i++) {
144              BI bi = new BI(i);
145              BS bs = new BS(String.valueOf(i));
146 <            LexicographicList<BI> bis = new LexicographicList<BI>(bi);
147 <            LexicographicList<BS> bss = new LexicographicList<BS>(bs);
146 >            LexicographicList<BI> bis = new LexicographicList<>(bi);
147 >            LexicographicList<BS> bss = new LexicographicList<>(bs);
148              assertNull(m.putIfAbsent(bis, true));
149              assertTrue(m.containsKey(bis));
150              if (m.putIfAbsent(bss, true) == null)
# Line 170 | Line 163 | public class ConcurrentHashMapTest exten
163       */
164      public void testGenericComparable2() {
165          int size = 500;         // makes measured test run time -> 60ms
166 <        ConcurrentHashMap<Object, Boolean> m =
174 <            new ConcurrentHashMap<Object, Boolean>();
166 >        ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
167          for (int i = 0; i < size; i++) {
168              m.put(Collections.singletonList(new BI(i)), true);
169          }
170  
171          for (int i = 0; i < size; i++) {
172 <            LexicographicList<BI> bis = new LexicographicList<BI>(new BI(i));
172 >            LexicographicList<BI> bis = new LexicographicList<>(new BI(i));
173              assertTrue(m.containsKey(bis));
174          }
175      }
# Line 188 | Line 180 | public class ConcurrentHashMapTest exten
180       */
181      public void testMixedComparable() {
182          int size = 1200;        // makes measured test run time -> 35ms
183 <        ConcurrentHashMap<Object, Object> map =
192 <            new ConcurrentHashMap<Object, Object>();
183 >        ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<>();
184          Random rng = new Random();
185          for (int i = 0; i < size; i++) {
186              Object x;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines