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())
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))
def test__eq___PASS(self): self.assertTrue(EMPTY.__eq__(EMPTY)) self.assertTrue(EMPTY.__eq__(())) self.assertTrue(EMPTY.__eq__([]))
def testSeq_PASS(self): self.assertEqual(EMPTY.seq(), None)
def test__iter___PASS(self): self.assertEqual(EMPTY.__iter__(), None)
def testCons_PASS(self): l = EMPTY.cons(uobj) self.assertFalse(EMPTY is l) self.assertEqual(len(l), 1) self.assertEqual(l.first(), uobj)
def testPeek_PASS(self): self.assertEqual(EMPTY.peek(), None)
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))
def testNext_PASS(self): self.assertEqual(EMPTY.next(), None)
def testEmpty_PASS(self): self.assertTrue(EMPTY.empty() is EMPTY)
def testMore_PASS(self): self.assertTrue(EMPTY.more() is EMPTY)
def testFirst_PASS(self): self.assertEqual(EMPTY.first(), None)
def test__ne___PASS(self): self.assertFalse(EMPTY.__ne__(EMPTY)) self.assertFalse(EMPTY.__ne__(())) self.assertFalse(EMPTY.__ne__([]))
def testCount_PASS(self): self.assertEqual(EMPTY.count(), 0)
def testWriteAsReplString_PASS(self): sio = StringIO() EMPTY.writeAsReplString(sio) self.assertEqual(sio.getvalue(), "()")
def test__len___PASS(self): self.assertEqual(EMPTY.__len__(), 0)
def test__hash___PASS(self): self.assertEqual(EMPTY.__hash__(), 1)