Commits

Roman Nefyodov  committed 6246dca

fix Set.add contract

  • Participants
  • Parent commits fa6de64

Comments (0)

Files changed (2)

File src/main/java/ru/yandex/bolts/collection/CollectionsFTest.java

         }
     }
 
+    public void testSetFromMap() {
+        SetF<Object> set = Cf.identityHashSet();
+        assertTrue(set.add(new Object()));
+        Object o = new Object();
+        assertTrue(set.add(o));
+        assertFalse(set.add(o));
+    }
+
     public void testRepeatEmpty() {
         ListF<String> set = Cf.repeat("a", 0);
         assertFalse(set.contains("a"));

File src/main/java/ru/yandex/bolts/collection/impl/SetFromMap.java

 
     @Override
     public boolean add(E o) {
-        return map.put(o, Boolean.TRUE) != null;
+        return map.put(o, Boolean.TRUE) == null;
     }
 
     @Override