2010-12-29 00:48:54 -05:00
|
|
|
# String Literals
|
|
|
|
# ---------------
|
|
|
|
|
|
|
|
# TODO: refactor string literal tests
|
2011-01-03 04:17:00 -05:00
|
|
|
# TODO: add indexing and method invocation tests: "string"["toString"] is String::toString, "string".toString() is "string"
|
2010-12-29 00:48:54 -05:00
|
|
|
|
2011-01-03 04:28:47 -05:00
|
|
|
# * Strings
|
|
|
|
# * Heredocs
|
|
|
|
|
2010-12-30 22:48:31 -05:00
|
|
|
test "backslash escapes", ->
|
|
|
|
eq "\\/\\\\", /\/\\/.source
|
|
|
|
|
2010-12-29 00:48:54 -05:00
|
|
|
eq '(((dollars)))', '\(\(\(dollars\)\)\)'
|
|
|
|
eq 'one two three', "one
|
|
|
|
two
|
|
|
|
three"
|
|
|
|
eq "four five", 'four
|
|
|
|
|
|
|
|
five'
|
|
|
|
|
|
|
|
#647
|
|
|
|
eq "''Hello, World\\''", '''
|
|
|
|
'\'Hello, World\\\''
|
|
|
|
'''
|
|
|
|
eq '""Hello, World\\""', """
|
|
|
|
"\"Hello, World\\\""
|
|
|
|
"""
|
|
|
|
eq 'Hello, World\n', '''
|
|
|
|
Hello, World\
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
a = """
|
|
|
|
basic heredoc
|
|
|
|
on two lines
|
|
|
|
"""
|
|
|
|
ok a is "basic heredoc\non two lines"
|
|
|
|
|
|
|
|
a = '''
|
|
|
|
a
|
|
|
|
"b
|
|
|
|
c
|
|
|
|
'''
|
|
|
|
ok a is "a\n \"b\nc"
|
|
|
|
|
|
|
|
a = """
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
"""
|
|
|
|
ok a is "a\n b\n c"
|
|
|
|
|
|
|
|
a = '''one-liner'''
|
|
|
|
ok a is 'one-liner'
|
|
|
|
|
|
|
|
a = """
|
|
|
|
out
|
|
|
|
here
|
|
|
|
"""
|
|
|
|
ok a is "out\nhere"
|
|
|
|
|
|
|
|
a = '''
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
'''
|
|
|
|
ok a is " a\n b\nc"
|
|
|
|
|
|
|
|
a = '''
|
|
|
|
a
|
|
|
|
|
|
|
|
|
|
|
|
b c
|
|
|
|
'''
|
|
|
|
ok a is "a\n\n\nb c"
|
|
|
|
|
|
|
|
a = '''more"than"one"quote'''
|
|
|
|
ok a is 'more"than"one"quote'
|
|
|
|
|
|
|
|
a = '''here's an apostrophe'''
|
|
|
|
ok a is "here's an apostrophe"
|
|
|
|
|
|
|
|
# The indentation detector ignores blank lines without trailing whitespace
|
|
|
|
a = """
|
|
|
|
one
|
|
|
|
two
|
|
|
|
|
|
|
|
"""
|
|
|
|
ok a is "one\ntwo\n"
|
|
|
|
|
|
|
|
eq ''' line 0
|
|
|
|
should not be relevant
|
|
|
|
to the indent level
|
|
|
|
''', '
|
|
|
|
line 0\n
|
|
|
|
should not be relevant\n
|
|
|
|
to the indent level
|
|
|
|
'
|
|
|
|
|
|
|
|
eq ''' '\\\' ''', " '\\' "
|
|
|
|
eq """ "\\\" """, ' "\\" '
|
|
|
|
|
|
|
|
eq ''' <- keep these spaces -> ''', ' <- keep these spaces -> '
|
2011-01-15 10:57:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
test "#1046, empty string interpolations", ->
|
|
|
|
eq "#{ }", ''
|