From 290645f3c92c7e725d9cd04aaacdddbd9cedcd28 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Tue, 26 Jun 2018 12:22:51 +0300 Subject: [PATCH] #44: do not trim last nil if array item list ends by a comma --- node/expr/t_array_test.go | 1 + node/expr/t_list_test.go | 34 ++++++++++++++ node/expr/t_short_array_test.go | 1 + php5/php5.go | 82 +++++++++++++++++---------------- php5/php5.y | 4 ++ php5/php5_test.go | 2 + php7/php7.go | 4 +- php7/php7.y | 4 +- php7/php7_test.go | 2 + 9 files changed, 91 insertions(+), 43 deletions(-) diff --git a/node/expr/t_array_test.go b/node/expr/t_array_test.go index 99d997a..2a8f5d4 100644 --- a/node/expr/t_array_test.go +++ b/node/expr/t_array_test.go @@ -81,6 +81,7 @@ func TestArrayItems(t *testing.T) { &expr.ArrayItem{ Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, }, + nil, }, }, }, diff --git a/node/expr/t_list_test.go b/node/expr/t_list_test.go index de00d55..8d362ac 100644 --- a/node/expr/t_list_test.go +++ b/node/expr/t_list_test.go @@ -173,3 +173,37 @@ func TestListEmptyItem(t *testing.T) { actual = php5parser.GetRootNode() assertEqual(t, expected, actual) } + +func TestListEmptyItems(t *testing.T) { + src := `