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

Function TestNewTokenNodeListPosition

positionbuilder/position_builder_test.go:211–243  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

209}
210
211func TestNewTokenNodeListPosition(t *testing.T) {
212 tkn := &scanner.Token{
213 Value: `foo`,
214 StartLine: 1,
215 EndLine: 1,
216 StartPos: 0,
217 EndPos: 2,
218 }
219
220 n1 := node.NewIdentifier("test node")
221 n1.SetPosition(&position.Position{
222 StartLine: 2,
223 EndLine: 2,
224 StartPos: 3,
225 EndPos: 10,
226 })
227
228 n2 := node.NewIdentifier("test node")
229 n2.SetPosition(&position.Position{
230 StartLine: 3,
231 EndLine: 3,
232 StartPos: 11,
233 EndPos: 20,
234 })
235
236 builder := positionbuilder.PositionBuilder{}
237
238 pos := builder.NewTokenNodeListPosition(tkn, []node.Node{n1, n2})
239
240 if pos.String() != `Pos{Line: 1-3 Pos: 0-20}` {
241 t.Errorf("token value is not equal\n")
242 }
243}
244
245func TestNewNodeNodeListPosition(t *testing.T) {
246 n1 := node.NewIdentifier("test node")

Callers

nothing calls this directly

Calls 4

SetPositionMethod · 0.95
NewIdentifierFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…