def test_triple_string_interpolation_single(): source = r''' puts """$greeting""" ''' assert parse(source) == [ Call(Ident('puts'), [InterpolatedString([Ident('greeting')])]) ]
def test_triple_interpolated_string_sigil(): source = r''' r"""hello ${"world"}""" ''' assert parse(source) == [ InterpolatedString([String('hello ', 'r'), String('world')]) ]
def test_triple_string_interpolation_leading_space(): source = r''' puts """ Hello, ${"John"}""" ''' assert parse(source) == [ Call(Ident('puts'), [InterpolatedString([String(' Hello, '), String('John')])]) ]
def test_triple_string_interpolation_empty(): source = r''' puts """Hello${""}!""" ''' assert parse(source) == [ Call(Ident('puts'), [InterpolatedString([String('Hello'), String(''), String('!')])]) ]
def test_triple_string_interpolation_nested(): source = r''' puts """Hello, ${1 + {2}}""" ''' assert parse(source) == [ Call(Ident('puts'), [ InterpolatedString( [String('Hello, '), BinarySlurp([Int(1), Ident('+'), Int(2)])]) ]) ]
def test_triple_string_interpolation_two_quotes_before_dollar(): source = r''' puts """Hello, ""${"John"}!""" ''' assert parse(source) == [ Call(Ident('puts'), [ InterpolatedString( [String('Hello, ""'), String('John'), String('!')]) ]) ]
def test_string_interpolation_single_inner(): source = r''' puts "Hello, $'John'!" ''' assert parse(source) == [ Call(Ident('puts'), [ InterpolatedString([ String('Hello, '), String('John'), String('!') ]) ]) ]
def test_triple_string_interpolation_call(): source = r''' puts """ Hello, $(last name) ${ "!" } """ ''' assert parse(source) == [ Call(Ident('puts'), [ InterpolatedString([ String(' Hello, '), Call(Ident('last'), [Ident('name')]), String(' '), String('!'), String(' ') ]) ]) ]
def test_triple_string_interpolation_compound(): source = r''' puts """ Hello, $name ${ "!" } """ ''' assert parse(source) == [ Call(Ident('puts'), [ InterpolatedString([ String(' Hello, '), Ident('name'), String(' '), String('!'), String(' ') ]) ]) ]