def testCall_FAIL(self): v = pv.vec([]) # no default argument allowed self.assertRaises(IndexOutOfBoundsException, v.__call__, 0) self.assertRaises(IndexOutOfBoundsException, v.__call__, 99) self.assertRaises(IndexOutOfBoundsException, v.__call__, -323)
def test__hash___PASS(self): v = pv.vec([1, 2, 3]) self.assertEqual(v.__hash__(), vecHash(v)) self.assertEqual(pv.EMPTY.__hash__(), 1)
def setUp(self): self.printV = pv.create(pv.EMPTY, pv.EMPTY) self.v3 = pv.vec(["x", "y", "z"])
def test__eq___PASS(self): v = pv.vec(["x", "y", "z"]) self.assertTrue(self.v3 == v) self.assertTrue(self.v3 == self.v3)
def testPop_FAIL(self): v = pv.vec([]) self.assertRaises(IllegalStateException, v.pop)
def testDerefVec_PASS(self): self.assertEqual(self.refOne.deref(), pv.vec(range(10)))
def setUp(self): # [0 1 2 3 4 5 6 7 8 9] # [4 5 6] self.parent = pv.vec(range(10)) self.sv = SubVec(pseudoMetaData, self.parent, 4, 7) self.oneItemSv = SubVec(None, self.parent, 0, 1)
def testAssocN_FAIL(self): v = pv.vec([]) self.assertRaises(IndexOutOfBoundsException, v.assocN, 2, uobj)
def testNth_FAIL(self): v = pv.vec([]) # no default argument given self.assertRaises(IndexOutOfBoundsException, v.nth, 0) self.assertRaises(IndexOutOfBoundsException, v.nth, 99) self.assertRaises(IndexOutOfBoundsException, v.nth, -2343)
def setUp(self): self.refZero = Ref(0, None) self.refOne = Ref(pv.vec(range(10)), None)
self.assertEqual(csio.getvalue(), "[[] []]") # str(v) def test__str___PASS(self): self.assertEqual(self.printV.__str__(), "[[], []]") # repr(v) def test__repr___PASS(self): regex = r"<clojure\.lang\.persistentvector\.PersistentVector" \ r" object at 0x[a-fA-F0-9]+ \[\[\] \[\]\]>$" self.assertTrue(re.match(regex, self.printV.__repr__())) testCreationMap_PASS = { # vec pv.vec([]): pv.EMPTY, pv.vec([uobj])._tail[0]: uobj, pv.vec([0, 0, uobj])._tail[2]: uobj, # create pv.create(): pv.EMPTY, pv.create(uobj)._tail[0]: uobj, pv.create(0, 0, uobj)._tail[2]: uobj, } testMetaDataMap_PASS = { pv.PersistentVector(pseudoMetaData, 0, 5, pv.EMPTY_NODE, []) \ .meta(): pseudoMetaData, pv.PersistentVector(pseudoMetaData, 0, 5, pv.EMPTY_NODE, []) \ .empty().meta(): pseudoMetaData, }
csio = StringIO() self.printV.writeAsReplString(csio) self.assertEqual(csio.getvalue(), "[[] []]") # str(v) def test__str___PASS(self): self.assertEqual(self.printV.__str__(), "[[], []]") # repr(v) def test__repr___PASS(self): regex = r"<clojure\.lang\.persistentvector\.PersistentVector" \ r" object at 0x[a-fA-F0-9]+ \[\[\] \[\]\]>$" self.assertTrue(re.match(regex, self.printV.__repr__())) testCreationMap_PASS = { # vec pv.vec([]): pv.EMPTY, pv.vec([uobj])._tail[0]: uobj, pv.vec([0, 0, uobj])._tail[2]: uobj, # create pv.create(): pv.EMPTY, pv.create(uobj)._tail[0]: uobj, pv.create(0, 0, uobj)._tail[2]: uobj, } testMetaDataMap_PASS = { pv.PersistentVector(pseudoMetaData, 0, 5, pv.EMPTY_NODE, []) \ .meta(): pseudoMetaData, pv.PersistentVector(pseudoMetaData, 0, 5, pv.EMPTY_NODE, []) \ .empty().meta(): pseudoMetaData, }