Пример #1
0
    def empty(self):
        """Return an empty Cons.

        The new seq will have this seq's meta data attached."""

        from clojure.lang.persistentlist import EMPTY
        return EMPTY.withMeta(self.meta())
Пример #2
0
def cons(x, s):
    from clojure.lang.cons import Cons
    from clojure.lang.persistentlist import EMPTY as EMPTY_LIST
    if isinstance(s, ISeq):
        return Cons(x, s)
    if s is None:
        return EMPTY_LIST.cons(x)
    return Cons(x, seq(s))
Пример #3
0
 def test__eq___PASS(self):
     self.assertTrue(EMPTY.__eq__(EMPTY))
     self.assertTrue(EMPTY.__eq__(()))
     self.assertTrue(EMPTY.__eq__([]))
Пример #4
0
 def testSeq_PASS(self):
     self.assertEqual(EMPTY.seq(), None)
Пример #5
0
 def test__iter___PASS(self):
     self.assertEqual(EMPTY.__iter__(), None)
Пример #6
0
 def testCons_PASS(self):
     l = EMPTY.cons(uobj)
     self.assertFalse(EMPTY is l)
     self.assertEqual(len(l), 1)
     self.assertEqual(l.first(), uobj)
Пример #7
0
 def testPeek_PASS(self):
     self.assertEqual(EMPTY.peek(), None)
Пример #8
0
 def testWithMeta_PASS(self):
     l1 = EMPTY.withMeta(pseudoMetaData)
     l2 = l1.withMeta(uobj)
     self.assertFalse(l1.meta() is l2.meta())
     # equal with different meta data
     self.assertTrue(l1.__eq__(l2))
Пример #9
0
 def testNext_PASS(self):
     self.assertEqual(EMPTY.next(), None)
Пример #10
0
 def testEmpty_PASS(self):
     self.assertTrue(EMPTY.empty() is EMPTY)
Пример #11
0
 def testPeek_PASS(self):
     self.assertEqual(EMPTY.peek(), None)
Пример #12
0
 def testMore_PASS(self):
     self.assertTrue(EMPTY.more() is EMPTY)
Пример #13
0
 def testCons_PASS(self):
     l = EMPTY.cons(uobj)
     self.assertFalse(EMPTY is l)
     self.assertEqual(len(l), 1)
     self.assertEqual(l.first(), uobj)
Пример #14
0
 def testNext_PASS(self):
     self.assertEqual(EMPTY.next(), None)
Пример #15
0
 def testFirst_PASS(self):
     self.assertEqual(EMPTY.first(), None)
Пример #16
0
 def testWithMeta_PASS(self):
     l1 = EMPTY.withMeta(pseudoMetaData)
     l2 = l1.withMeta(uobj)
     self.assertFalse(l1.meta() is l2.meta())
     # equal with different meta data
     self.assertTrue(l1.__eq__(l2))
Пример #17
0
 def test__ne___PASS(self):
     self.assertFalse(EMPTY.__ne__(EMPTY))
     self.assertFalse(EMPTY.__ne__(()))
     self.assertFalse(EMPTY.__ne__([]))
Пример #18
0
 def testCount_PASS(self):
     self.assertEqual(EMPTY.count(), 0)
Пример #19
0
 def test__iter___PASS(self):
     self.assertEqual(EMPTY.__iter__(), None)
Пример #20
0
 def testSeq_PASS(self):
     self.assertEqual(EMPTY.seq(), None)
Пример #21
0
 def testFirst_PASS(self):
     self.assertEqual(EMPTY.first(), None)
Пример #22
0
 def testWriteAsReplString_PASS(self):
     sio = StringIO()
     EMPTY.writeAsReplString(sio)
     self.assertEqual(sio.getvalue(), "()")
Пример #23
0
 def testMore_PASS(self):
     self.assertTrue(EMPTY.more() is EMPTY)
Пример #24
0
 def test__len___PASS(self):
     self.assertEqual(EMPTY.__len__(), 0)
Пример #25
0
 def testEmpty_PASS(self):
     self.assertTrue(EMPTY.empty() is EMPTY)
Пример #26
0
 def test__len___PASS(self):
     self.assertEqual(EMPTY.__len__(), 0)
Пример #27
0
 def testCount_PASS(self):
     self.assertEqual(EMPTY.count(), 0)
Пример #28
0
 def test__eq___PASS(self):
     self.assertTrue(EMPTY.__eq__(EMPTY))
     self.assertTrue(EMPTY.__eq__(()))
     self.assertTrue(EMPTY.__eq__([]))
Пример #29
0
 def testWriteAsReplString_PASS(self):
     sio = StringIO()
     EMPTY.writeAsReplString(sio)
     self.assertEqual(sio.getvalue(), "()")
Пример #30
0
 def test__ne___PASS(self):
     self.assertFalse(EMPTY.__ne__(EMPTY))
     self.assertFalse(EMPTY.__ne__(()))
     self.assertFalse(EMPTY.__ne__([]))
Пример #31
0
 def test__hash___PASS(self):
     self.assertEqual(EMPTY.__hash__(), 1)
Пример #32
0
 def test__hash___PASS(self):
     self.assertEqual(EMPTY.__hash__(), 1)