def test_tuple_deconstruction(): source = ''' (name, occupation) = ("John Smith", @farmer) ''' assert parse(source) == [ BinarySlurp([ Tuple([Ident('name'), Ident('occupation')]), Ident('='), Tuple([String('John Smith'), Symbol('farmer')]) ]) ]
def test_whitespace_single_tuple(): source = ''' ( fn, ) ''' assert parse(source) == [Tuple([Ident('fn')])]
def test_empty_tuple(): source = ''' tuple = () ''' assert parse(source) == [ BinarySlurp([Ident('tuple'), Ident('='), Tuple()]) ]
def test_simple_call_statement(): source = ''' puts.("Hello, World!",) ''' assert parse(source) == [ BinarySlurp( [Ident('puts'), Ident('.'), Tuple([String("Hello, World!")])]) ]
def test_whitespace_tuple(): source = ''' ( fn, arg1, arg2, ) ''' assert parse(source) == [ Tuple([Ident('fn'), Ident('arg1'), Ident('arg2')]) ]
def test_if_not(): source = ''' if (not thing.()) puts "badness" ''' assert parse(source) == [ Call(Ident('if'), [ Call(Ident('not'), [BinarySlurp([Ident('thing'), Ident('.'), Tuple()])]), Block([Call(Ident('puts'), [String('badness')])]) ]) ]
def test_single_tuple(): source = ''' tuple = ("thing" -> "place",) ''' assert parse(source) == [ BinarySlurp([ Ident('tuple'), Ident('='), Tuple([ BinarySlurp([String('thing'), Ident('->'), String('place')]), ]) ]) ]
def test_tuple_trailing(): source = ''' tuple = ("thing" -> "place", 2 -> 3, 5 -> (compute "number"),) ''' assert parse(source) == [ BinarySlurp([ Ident('tuple'), Ident('='), Tuple([ BinarySlurp([String('thing'), Ident('->'), String('place')]), BinarySlurp([Int(2), Ident('->'), Int(3)]), BinarySlurp([ Int(5), Ident('->'), Call(Ident('compute'), [String('number')]) ]) ]) ]) ]