MCPcopy Create free account
hub / github.com/z7zmey/php-parser / TestArrayItem

Function TestArrayItem

node/expr/t_array_test.go:59–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestArrayItem(t *testing.T) {
60 src := `<? array(1);`
61
62 expected := &node.Root{
63 Position: &position.Position{
64 StartLine: 1,
65 EndLine: 1,
66 StartPos: 3,
67 EndPos: 12,
68 },
69 Stmts: []node.Node{
70 &stmt.Expression{
71 Position: &position.Position{
72 StartLine: 1,
73 EndLine: 1,
74 StartPos: 3,
75 EndPos: 12,
76 },
77 Expr: &expr.Array{
78 Position: &position.Position{
79 StartLine: 1,
80 EndLine: 1,
81 StartPos: 3,
82 EndPos: 11,
83 },
84 Items: []node.Node{
85 &expr.ArrayItem{
86 Position: &position.Position{
87 StartLine: 1,
88 EndLine: 1,
89 StartPos: 9,
90 EndPos: 10,
91 },
92 Val: &scalar.Lnumber{
93 Position: &position.Position{
94 StartLine: 1,
95 EndLine: 1,
96 StartPos: 9,
97 EndPos: 10,
98 },
99 Value: "1",
100 },
101 },
102 },
103 },
104 },
105 },
106 }
107
108 php7parser := php7.NewParser([]byte(src), "7.4")
109 php7parser.Parse()
110 actual := php7parser.GetRootNode()
111 assert.DeepEqual(t, expected, actual)
112
113 php5parser := php5.NewParser([]byte(src), "5.6")
114 php5parser.Parse()
115 actual = php5parser.GetRootNode()
116 assert.DeepEqual(t, expected, actual)

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
GetRootNodeMethod · 0.95
NewParserFunction · 0.92
NewParserFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…