def test_parse_list(): assert parse(['(', '1', '2', ')']) == List([1, 2]) assert parse(['(', '1', '(', '2', '3', ')', ')']) == \ List([1, List([2, 3])]) assert parse(['(', '(', '1', '2', ')', '3', ')']) == \ List([List([1, 2]), 3]) assert parse(['(', '1', '(', '2', ')', '3', ')']) == \ List([1, List([2]), 3]) assert parse(['(', '(', '1', ')', '(', '2', ')', ')']) == \ List([List([1]), List([2])])
def test_parse_unmatched(): with raises(SyntaxError): assert parse(['('])
def test_parse_map(): assert parse(['{', '1', '2', '}']) == {1: 2} assert parse(['{', '1', '2', '3', '4', '}']) == {1: 2, 3: 4} assert parse(['{', '1', '2', '3', '}']) == {1: 2}
def test_parse_vector(): assert parse(['[', '1', '2', ']']) == [1, 2]
def test_bool(): assert parse(['true']) == True assert parse(['true']) == parse(['true']) assert not parse(['false']) assert parse(['false']) == False
def test_read_atom(): assert parse(['1']) == 1 assert parse(['1/3']) == Fraction(1, 3) assert parse(['true']) assert parse(['nil']) == Nil()