@@ -1180,16 +1180,17 @@ describe "Parser" do
1180
1180
it_parses %( "hello " \\\n "world") , StringLiteral .new(" hello world" )
1181
1181
it_parses %( "hello "\\\n "world") , StringLiteral .new(" hello world" )
1182
1182
it_parses %( "hello \# {1}" \\\n "\# {2} world") , StringInterpolation .new([" hello " .string, 1 .int32, 2 .int32, " world" .string] of ASTNode )
1183
- it_parses " <<-HERE\n Hello, mom! I am HERE.\n HER dress is beautiful.\n HE is OK.\n HERESY\n HERE" , " Hello, mom! I am HERE.\n HER dress is beautiful.\n HE is OK.\n HERESY" .string
1184
- it_parses " <<-HERE\n One\n Zero\n HERE" , " One\n Zero" .string
1185
- it_parses " <<-HERE\n One \\ n Two\n Zero\n HERE" , " One \n Two\n Zero" .string
1186
- it_parses " <<-HERE\n One\n\n Zero\n HERE" , " One\n\n Zero" .string
1187
- it_parses " <<-HERE\n One\n \n Zero\n HERE" , " One\n\n Zero" .string
1183
+ it_parses " <<-HERE\n Hello, mom! I am HERE.\n HER dress is beautiful.\n HE is OK.\n HERESY\n HERE" ,
1184
+ " Hello, mom! I am HERE.\n HER dress is beautiful.\n HE is OK.\n HERESY" .string_interpolation
1185
+ it_parses " <<-HERE\n One\n Zero\n HERE" , " One\n Zero" .string_interpolation
1186
+ it_parses " <<-HERE\n One \\ n Two\n Zero\n HERE" , " One \n Two\n Zero" .string_interpolation
1187
+ it_parses " <<-HERE\n One\n\n Zero\n HERE" , " One\n\n Zero" .string_interpolation
1188
+ it_parses " <<-HERE\n One\n \n Zero\n HERE" , " One\n\n Zero" .string_interpolation
1188
1189
it_parses " <<-HERE\n \# {1}One\n \# {2}Zero\n HERE" , StringInterpolation .new([" " .string, 1 .int32, " One\n " .string, 2 .int32, " Zero" .string] of ASTNode )
1189
1190
it_parses " <<-HERE\n foo\# {1}bar\n baz\n HERE" , StringInterpolation .new([" foo" .string, 1 .int32, " bar\n baz" .string] of ASTNode )
1190
- it_parses " <<-HERE\r\n One\r\n Zero\r\n HERE" , " One\r\n Zero" .string
1191
- it_parses " <<-HERE\r\n One\r\n Zero\r\n HERE\r\n " , " One\r\n Zero" .string
1192
- it_parses " <<-SOME\n Sa\n Se\n SOME" , " Sa\n Se" .string
1191
+ it_parses " <<-HERE\r\n One\r\n Zero\r\n HERE" , " One\r\n Zero" .string_interpolation
1192
+ it_parses " <<-HERE\r\n One\r\n Zero\r\n HERE\r\n " , " One\r\n Zero" .string_interpolation
1193
+ it_parses " <<-SOME\n Sa\n Se\n SOME" , " Sa\n Se" .string_interpolation
1193
1194
it_parses " <<-HERE\n \# {1} \# {2}\n HERE" , StringInterpolation .new([1 .int32, " " .string, 2 .int32] of ASTNode )
1194
1195
it_parses " <<-HERE\n \# {1} \\ n \# {2}\n HERE" , StringInterpolation .new([1 .int32, " \n " .string, 2 .int32] of ASTNode )
1195
1196
assert_syntax_error " <<-HERE\n One\n wrong\n Zero\n HERE" , " heredoc line must have an indent greater or equal than 2" , 3 , 1
@@ -1200,16 +1201,24 @@ describe "Parser" do
1200
1201
assert_syntax_error " <<-HERE\n One\n \# {1}\n HERE" , " heredoc line must have an indent greater or equal than 2" , 2 , 1
1201
1202
assert_syntax_error %( "foo" "bar")
1202
1203
1203
- it_parses " <<-'HERE'\n hello \\ n world\n \# {1}\n HERE" , StringLiteral .new( " hello \\ n world\n\# {1}" )
1204
+ it_parses " <<-'HERE'\n hello \\ n world\n \# {1}\n HERE" , " hello \\ n world\n\# {1}" .string_interpolation
1204
1205
assert_syntax_error " <<-'HERE\n " , " expecting closing single quote"
1205
1206
1206
- it_parses " <<-FOO\n 1\n FOO.bar" , Call .new(" 1" .string, " bar" )
1207
- it_parses " <<-FOO\n 1\n FOO + 2" , Call .new(" 1" .string, " +" , 2 .int32)
1207
+ it_parses " <<-'HERE COMES HEREDOC'\n hello \\ n world\n \# {1}\n HERE COMES HEREDOC" , " hello \\ n world\n\# {1}" .string_interpolation
1208
1208
1209
- it_parses " <<-FOO\n\t 1\n\t FOO" , StringLiteral .new(" 1" )
1210
- it_parses " <<-FOO\n \t 1\n \t FOO" , StringLiteral .new(" 1" )
1211
- it_parses " <<-FOO\n \t 1\n \t FOO" , StringLiteral .new(" 1" )
1212
- it_parses " <<-FOO\n\t 1\n\t FOO" , StringLiteral .new(" 1" )
1209
+ assert_syntax_error " <<-FOO\n 1\n FOO.bar" , " Unterminated heredoc: can't find \" FOO\" anywhere before the end of file"
1210
+ assert_syntax_error " <<-FOO\n 1\n FOO + 2" , " Unterminated heredoc: can't find \" FOO\" anywhere before the end of file"
1211
+
1212
+ it_parses " <<-FOO\n\t 1\n\t FOO" , " 1" .string_interpolation
1213
+ it_parses " <<-FOO\n \t 1\n \t FOO" , " 1" .string_interpolation
1214
+ it_parses " <<-FOO\n \t 1\n \t FOO" , " 1" .string_interpolation
1215
+ it_parses " <<-FOO\n\t 1\n\t FOO" , " 1" .string_interpolation
1216
+
1217
+ it_parses " x, y = <<-FOO, <<-BAR\n hello\n FOO\n world\n BAR" ,
1218
+ MultiAssign .new([" x" .var, " y" .var] of ASTNode , [" hello" .string_interpolation, " world" .string_interpolation] of ASTNode )
1219
+
1220
+ it_parses " x, y, z = <<-FOO, <<-BAR, <<-BAZ\n hello\n FOO\n world\n BAR\n !\n BAZ" ,
1221
+ MultiAssign .new([" x" .var, " y" .var, " z" .var] of ASTNode , [" hello" .string_interpolation, " world" .string_interpolation, " !" .string_interpolation] of ASTNode )
1213
1222
1214
1223
it_parses " enum Foo; A\n B, C\n D = 1; end" , EnumDef .new(" Foo" .path, [Arg .new(" A" ), Arg .new(" B" ), Arg .new(" C" ), Arg .new(" D" , 1 .int32)] of ASTNode )
1215
1224
it_parses " enum Foo; A = 1, B; end" , EnumDef .new(" Foo" .path, [Arg .new(" A" , 1 .int32), Arg .new(" B" )] of ASTNode )
0 commit comments