예제 #1
0
 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)
예제 #2
0
 def test__hash___PASS(self):
     v = pv.vec([1, 2, 3])
     self.assertEqual(v.__hash__(), vecHash(v))
     self.assertEqual(pv.EMPTY.__hash__(), 1)
예제 #3
0
 def setUp(self):
     self.printV = pv.create(pv.EMPTY, pv.EMPTY)
     self.v3 = pv.vec(["x", "y", "z"])
 def test__hash___PASS(self):
     v = pv.vec([1, 2, 3])
     self.assertEqual(v.__hash__(), vecHash(v))
     self.assertEqual(pv.EMPTY.__hash__(), 1)
예제 #5
0
 def test__eq___PASS(self):
     v = pv.vec(["x", "y", "z"])
     self.assertTrue(self.v3 == v)
     self.assertTrue(self.v3 == self.v3)
예제 #6
0
 def testPop_FAIL(self):
     v = pv.vec([])
     self.assertRaises(IllegalStateException, v.pop)
예제 #7
0
 def testDerefVec_PASS(self):
     self.assertEqual(self.refOne.deref(), pv.vec(range(10)))
 def test__eq___PASS(self):
     v = pv.vec(["x", "y", "z"])
     self.assertTrue(self.v3 == v)
     self.assertTrue(self.v3 == self.v3)
예제 #9
0
 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 testPop_FAIL(self):
     v = pv.vec([])
     self.assertRaises(IllegalStateException, v.pop)
 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 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 setUp(self):
     self.printV = pv.create(pv.EMPTY, pv.EMPTY)
     self.v3 = pv.vec(["x", "y", "z"])
예제 #15
0
 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)
예제 #16
0
 def setUp(self):
     self.refZero = Ref(0, None)
     self.refOne = Ref(pv.vec(range(10)), None)
예제 #17
0
 def testAssocN_FAIL(self):
     v = pv.vec([])
     self.assertRaises(IndexOutOfBoundsException, v.assocN, 2, uobj)
예제 #18
0
 def testDerefVec_PASS(self):
     self.assertEqual(self.refOne.deref(), pv.vec(range(10)))
예제 #19
0
 def setUp(self):
     self.refZero = Ref(0, None)
     self.refOne = Ref(pv.vec(range(10)), None)
예제 #20
0
        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,
    }
예제 #21
0
 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)
        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,
    }