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

Function TestConstFetchRelative

node/expr/t_const_fetch_test.go:79–137  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestConstFetchRelative(t *testing.T) {
80 src := `<? namespace\foo;`
81
82 expected := &node.Root{
83 Position: &position.Position{
84 StartLine: 1,
85 EndLine: 1,
86 StartPos: 3,
87 EndPos: 17,
88 },
89 Stmts: []node.Node{
90 &stmt.Expression{
91 Position: &position.Position{
92 StartLine: 1,
93 EndLine: 1,
94 StartPos: 3,
95 EndPos: 17,
96 },
97 Expr: &expr.ConstFetch{
98 Position: &position.Position{
99 StartLine: 1,
100 EndLine: 1,
101 StartPos: 3,
102 EndPos: 16,
103 },
104 Constant: &name.Relative{
105 Position: &position.Position{
106 StartLine: 1,
107 EndLine: 1,
108 StartPos: 3,
109 EndPos: 16,
110 },
111 Parts: []node.Node{
112 &name.NamePart{
113 Position: &position.Position{
114 StartLine: 1,
115 EndLine: 1,
116 StartPos: 13,
117 EndPos: 16,
118 },
119 Value: "foo",
120 },
121 },
122 },
123 },
124 },
125 },
126 }
127
128 php7parser := php7.NewParser([]byte(src), "7.4")
129 php7parser.Parse()
130 actual := php7parser.GetRootNode()
131 assert.DeepEqual(t, expected, actual)
132
133 php5parser := php5.NewParser([]byte(src), "5.6")
134 php5parser.Parse()
135 actual = php5parser.GetRootNode()
136 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…