issue #2 - fix template string scanning

`l.Prev.Rune` is actually current rune and `c` is next rune.
This commit is contained in:
z7zmey
2018-03-29 16:46:21 +03:00
parent 685b7b25bd
commit 83bb761062
4 changed files with 101 additions and 38 deletions

View File

@@ -36,6 +36,30 @@ func TestSimpleVar(t *testing.T) {
assertEqual(t, expected, actual)
}
func TestSimpleVarEndsEcapsed(t *testing.T) {
src := `<? "test $var\"";`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &scalar.Encapsed{
Parts: []node.Node{
&scalar.EncapsedStringPart{Value: "test "},
&expr.Variable{VarName: &node.Identifier{Value: "var"}},
&scalar.EncapsedStringPart{Value: "\\\""},
},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestSimpleVarPropertyFetch(t *testing.T) {
src := `<? "test $foo->bar()";`