Add a few more string interpolation tests

Originally wanted to simplify the pretty-printer output, but ...
edge cases everywhere :/
This commit is contained in:
Nikita Popov 2015-03-11 19:02:44 +01:00
parent 5567f0ab3b
commit 4dbf067b4b
2 changed files with 82 additions and 2 deletions

View File

@ -13,6 +13,12 @@ Encapsed strings
"${A}";
"${A['B']}";
"${$A}";
"\{$A}";
"\{ $A }";
"\\{$A}";
"\\{ $A }";
"{$$A}[B]";
"$$A[B]";
"A $B C";
b"$A";
-----
@ -130,6 +136,64 @@ array(
)
)
11: Scalar_Encapsed(
parts: array(
0: \{
1: Expr_Variable(
name: A
)
2: }
)
)
12: Scalar_Encapsed(
parts: array(
0: \{
1: Expr_Variable(
name: A
)
2: }
)
)
13: Scalar_Encapsed(
parts: array(
0: \
1: Expr_Variable(
name: A
)
)
)
14: Scalar_Encapsed(
parts: array(
0: \{
1: Expr_Variable(
name: A
)
2: }
)
)
15: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: Expr_Variable(
name: A
)
)
1: [B]
)
)
16: Scalar_Encapsed(
parts: array(
0: $
1: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: B
)
)
)
)
17: Scalar_Encapsed(
parts: array(
0: A
1: Expr_Variable(
@ -138,7 +202,7 @@ array(
2: C
)
)
12: Scalar_Encapsed(
18: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A

View File

@ -55,9 +55,17 @@ STR;
// strings (normalized to double quoted)
"$a";
"a$b";
"$a$b";
"$a $b";
"a${b}c";
"a{$b}c";
"a$a[b]c";
"\{$A}";
"\{ $A }";
"\\{$A}";
"\\{ $A }";
"{$$A}[B]";
"$$A[B]";
<<<STR
a\nb$a\n{$b}
STR;
@ -119,9 +127,17 @@ b';
// strings (normalized to double quoted)
"{$a}";
"a{$b}";
"{$a}{$b}";
"{$a} {$b}";
"a{$b}c";
"a{$b}c";
"a{$a['b']}c";
"\\{{$A}}";
"\\{ {$A} }";
"\\{$A}";
"\\{ {$A} }";
"{${$A}}[B]";
"\${$A['B']}";
"a\nb{$a}\n{$b}";
// make sure indentation doesn't mess anything up
function foo()