Skip to content

Instantly share code, notes, and snippets.

@dfilimon
Created November 12, 2012 13:03
Show Gist options
  • Save dfilimon/4059290 to your computer and use it in GitHub Desktop.
Save dfilimon/4059290 to your computer and use it in GitHub Desktop.
AbstractSymbol not hashable properly
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import com.google.common.collect.Sets;
public class AbstractSymbolTest {
@Test
public void testHashSet() {
Set<AbstractSymbol> set = Sets.newHashSet();
AbstractSymbol symbol = new IdSymbol("test1", 5, 0);
assertTrue(set.add(symbol));
assertTrue(set.contains(symbol));
assertFalse(set.add(symbol));
AbstractSymbol symbol2 = (AbstractSymbol)symbol.clone();
assertTrue(symbol.equals(symbol2));
assertFalse(set.add(symbol2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment