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

Function TestPrintStmtListNested

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

Source from the content-addressed store, hash-verified

3668}
3669
3670func TestPrintStmtListNested(t *testing.T) {
3671 o := bytes.NewBufferString("")
3672
3673 p := printer.NewPrettyPrinter(o, " ")
3674 p.Print(&stmt.StmtList{
3675 Stmts: []node.Node{
3676 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
3677 &stmt.StmtList{
3678 Stmts: []node.Node{
3679 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
3680 &stmt.StmtList{
3681 Stmts: []node.Node{
3682 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}}},
3683 },
3684 },
3685 },
3686 },
3687 },
3688 })
3689
3690 expected := `{
3691 $a;
3692 {
3693 $b;
3694 {
3695 $c;
3696 }
3697 }
3698}`
3699 actual := o.String()
3700
3701 if expected != actual {
3702 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3703 }
3704}
3705
3706func TestPrintStmtSwitch(t *testing.T) {
3707 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…