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

Function TestPrinterPrintExprArray

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

Source from the content-addressed store, hash-verified

1571}
1572
1573func TestPrinterPrintExprArray(t *testing.T) {
1574 o := bytes.NewBufferString("")
1575
1576 p := printer.NewPrinter(o)
1577 p.Print(&expr.Array{
1578 Items: []node.Node{
1579 &expr.ArrayItem{
1580 Key: &scalar.String{Value: "'Hello'"},
1581 Val: &expr.Variable{
1582 VarName: &node.Identifier{Value: "world"},
1583 },
1584 },
1585 &expr.ArrayItem{
1586 Key: &scalar.Lnumber{Value: "2"},
1587 Val: &expr.Reference{Variable: &expr.Variable{
1588 VarName: &node.Identifier{Value: "var"},
1589 }},
1590 },
1591 &expr.ArrayItem{
1592 Val: &expr.Variable{
1593 VarName: &node.Identifier{Value: "var"},
1594 },
1595 },
1596 },
1597 })
1598
1599 expected := `array('Hello'=>$world,2=>&$var,$var)`
1600 actual := o.String()
1601
1602 if expected != actual {
1603 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
1604 }
1605}
1606
1607func TestPrinterPrintExprBitwiseNot(t *testing.T) {
1608 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…