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

Function TestVariable

node/expr/t_variable_test.go:17–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestVariable(t *testing.T) {
18 src := `<? $a;`
19
20 expected := &node.Root{
21 Position: &position.Position{
22 StartLine: 1,
23 EndLine: 1,
24 StartPos: 3,
25 EndPos: 6,
26 },
27 Stmts: []node.Node{
28 &stmt.Expression{
29 Position: &position.Position{
30 StartLine: 1,
31 EndLine: 1,
32 StartPos: 3,
33 EndPos: 6,
34 },
35 Expr: &expr.Variable{
36 Position: &position.Position{
37 StartLine: 1,
38 EndLine: 1,
39 StartPos: 3,
40 EndPos: 5,
41 },
42 VarName: &node.Identifier{
43 Position: &position.Position{
44 StartLine: 1,
45 EndLine: 1,
46 StartPos: 3,
47 EndPos: 5,
48 },
49 Value: "a",
50 },
51 },
52 },
53 },
54 }
55
56 php7parser := php7.NewParser([]byte(src), "7.4")
57 php7parser.Parse()
58 actual := php7parser.GetRootNode()
59 assert.DeepEqual(t, expected, actual)
60
61 php5parser := php5.NewParser([]byte(src), "5.6")
62 php5parser.Parse()
63 actual = php5parser.GetRootNode()
64 assert.DeepEqual(t, expected, actual)
65}
66
67func TestVariableVariable(t *testing.T) {
68 src := `<? $$a;`

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…