def __init__(self, *args, **kwargs): if(len(args) == 1) and isinstance(args[0], Sequence): Sort.__init__(self) if len(args[0]) == 0: self._generator = String.empty else: self._generator = String.cons self._generator_args = {'tail': String(args[0][:-1]), 'head': Char((args[0][-1]))} else: Sort.__init__(self, **kwargs)
def test_generator(): assert String.empty()._generator == String.empty assert String.cons(tail=String.empty(), head=Char('a'))._generator == String.cons
def test_pop(): assert String('abc').pop() == (String('ab'), Char('c')) assert String([]).pop() == (String.empty(), String.empty())
def test_constructor(): assert String('') == String.empty() assert String('ab') == String.cons(tail=String.cons(tail=String.empty(), head=Char('a')), head=Char('b'))
def test_constructor(): assert Char('a') == Char.char(Nat(97))
def test_generator(): assert Char.char(Nat(10))._generator == Char.char
def test_str_(): assert Char('a').__str__() == 'Char(a)'