Exemplo n.º 1
0
 def testScaling(self):
     m = PersistentTreeMap()
     ints = range(1000)
     shuffle(ints)
     for i in ints:
         m = m.assoc(i, randint(1, 10))
     self.assertEqual(m.count(), 1000)
Exemplo n.º 2
0
 def testAddRemove(self):
     m = PersistentTreeMap()
     ints = range(100)
     shuffle(ints)
     for i in ints:
         m = m.assoc(i, randint(1, 10))
     for i in ints[:10]:
         m = m.without(i)
     self.assertEqual(m.count(), 90)
Exemplo n.º 3
0
 def testMaxKey(self):
     m = PersistentTreeMap().assoc('a', 1).assoc('b', 2)
     self.assertEqual(m.maxKey(), 'b')
Exemplo n.º 4
0
 def testValAt(self):
     m = PersistentTreeMap().assoc('a', 1)
     self.assertEqual(m.valAt('a'), 1)
Exemplo n.º 5
0
 def testVals(self):
     m = PersistentTreeMap().assoc('a', 1).assoc('b', 2)
     vals = m.vals()
     self.assertEqual(vals.next(), 1)
     self.assertEqual(vals.next(), 2)
Exemplo n.º 6
0
 def testKeys(self):
     m = PersistentTreeMap().assoc('a', 1).assoc('b', 2)
     keys = m.keys()
     self.assertEqual(keys.next(), 'a')
     self.assertEqual(keys.next(), 'b')
Exemplo n.º 7
0
    def testSeq(self):
        self.assertEqual(PersistentTreeMap().seq(), None)

        m = PersistentTreeMap().assoc('a', 1).assoc('b', 2)
        self.assertEqual(m.seq().first().key(), 'a')
        self.assertEqual(m.seq().next().first().key(), 'b')
Exemplo n.º 8
0
 def testWithout(self):
     m = PersistentTreeMap().assoc('a', 1).without('a')
     self.assertFalse(m.containsKey('a'))
Exemplo n.º 9
0
 def testAssoc(self):
     m = PersistentTreeMap().assoc('a', 1)
     self.assertTrue(m.containsKey('a'))