def test_hashtrie_like_mutable(): space = Space() t = PersistentHashTrie(space) t._set_item(String("foobar"), String("foobarval")) t._set_item(String("foobar2"), String("foobarval2")) assert space.eq(t.get_item(String("foobar")), String("foobarval")) assert space.eq(t.get_item(String("foobar2")), String("foobarval2")) assert len(t.keys()) == 2 assert space.eq(t.keys()[0], String("foobar")) or space.eq(t.keys()[1], String("foobar")) assert space.eq(t.keys()[0], String("foobar2")) or space.eq(t.keys()[1], String("foobar2"))
def skip_test_hashtrie_like_mutable_collisions(): space = Space() t = PersistentHashTrie(space) # two different objects with same hash a = HashAndEqSimulator(100, 1) b = HashAndEqSimulator(100, 2) t._set_item(a, String("a")) t._set_item(b, String("b")) assert space.eq(t.get_item(a), String("a")) assert space.eq(t.get_item(b), String("b")) assert len(t.keys()) == 2
def test_hashtrie_like_mutable_with_many(): space = Space() t = PersistentHashTrie(space) items = [String("foo%d" % i) for i in xrange(200)] for item in items: t._set_item(item, item) for item in items: assert space.eq(t.get_item(item), item) for item in items: t._set_item(item, item) assert space.eq(t.get_item(item), item) for item in items: assert space.eq(t.get_item(item), item) assert len(t.keys()) == len(items)