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

Function TestPrintExprShortArray

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

Source from the content-addressed store, hash-verified

1858}
1859
1860func TestPrintExprShortArray(t *testing.T) {
1861 o := bytes.NewBufferString("")
1862
1863 p := printer.NewPrettyPrinter(o, " ")
1864 p.Print(&expr.ShortArray{
1865 Items: []node.Node{
1866 &expr.ArrayItem{
1867 Key: &scalar.String{Value: "'Hello'"},
1868 Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}},
1869 },
1870 &expr.ArrayItem{
1871 Key: &scalar.Lnumber{Value: "2"},
1872 Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}},
1873 },
1874 &expr.ArrayItem{
1875 Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
1876 },
1877 },
1878 })
1879
1880 expected := `['Hello' => $world, 2 => &$var, $var]`
1881 actual := o.String()
1882
1883 if expected != actual {
1884 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
1885 }
1886}
1887
1888func TestPrintShortList(t *testing.T) {
1889 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…