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

Function TestPrinterPrintExprShortArray

printer/printer_test.go:2292–2324  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2290}
2291
2292func TestPrinterPrintExprShortArray(t *testing.T) {
2293 o := bytes.NewBufferString("")
2294
2295 p := printer.NewPrinter(o)
2296 p.Print(&expr.ShortArray{
2297 Items: []node.Node{
2298 &expr.ArrayItem{
2299 Key: &scalar.String{Value: "'Hello'"},
2300 Val: &expr.Variable{
2301 VarName: &node.Identifier{Value: "world"},
2302 },
2303 },
2304 &expr.ArrayItem{
2305 Key: &scalar.Lnumber{Value: "2"},
2306 Val: &expr.Reference{Variable: &expr.Variable{
2307 VarName: &node.Identifier{Value: "var"},
2308 }},
2309 },
2310 &expr.ArrayItem{
2311 Val: &expr.Variable{
2312 VarName: &node.Identifier{Value: "var"},
2313 },
2314 },
2315 },
2316 })
2317
2318 expected := `['Hello'=>$world,2=>&$var,$var]`
2319 actual := o.String()
2320
2321 if expected != actual {
2322 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2323 }
2324}
2325
2326func TestPrinterPrintShortList(t *testing.T) {
2327 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…