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

Function TestPrintExprArray

printer/pretty_printer_test.go:1281–1307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1279}
1280
1281func TestPrintExprArray(t *testing.T) {
1282 o := bytes.NewBufferString("")
1283
1284 p := printer.NewPrettyPrinter(o, " ")
1285 p.Print(&expr.Array{
1286 Items: []node.Node{
1287 &expr.ArrayItem{
1288 Key: &scalar.String{Value: "'Hello'"},
1289 Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}},
1290 },
1291 &expr.ArrayItem{
1292 Key: &scalar.Lnumber{Value: "2"},
1293 Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}},
1294 },
1295 &expr.ArrayItem{
1296 Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
1297 },
1298 },
1299 })
1300
1301 expected := `array('Hello' => $world, 2 => &$var, $var)`
1302 actual := o.String()
1303
1304 if expected != actual {
1305 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
1306 }
1307}
1308
1309func TestPrintExprBitwiseNot(t *testing.T) {
1310 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrettyPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…