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

Function TestPrinterPrintAltFor

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

Source from the content-addressed store, hash-verified

2652}
2653
2654func TestPrinterPrintAltFor(t *testing.T) {
2655 o := bytes.NewBufferString("")
2656
2657 p := printer.NewPrinter(o)
2658 p.Print(&stmt.AltFor{
2659 Init: []node.Node{
2660 &expr.Variable{
2661 VarName: &node.Identifier{Value: "a"},
2662 },
2663 },
2664 Cond: []node.Node{
2665 &expr.Variable{
2666 VarName: &node.Identifier{Value: "b"},
2667 },
2668 },
2669 Loop: []node.Node{
2670 &expr.Variable{
2671 VarName: &node.Identifier{Value: "c"},
2672 },
2673 },
2674 Stmt: &stmt.StmtList{
2675 Stmts: []node.Node{
2676 &stmt.Expression{Expr: &expr.Variable{
2677 VarName: &node.Identifier{Value: "d"},
2678 }},
2679 },
2680 },
2681 })
2682
2683 expected := `for($a;$b;$c):$d;endfor;`
2684 actual := o.String()
2685
2686 if expected != actual {
2687 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2688 }
2689}
2690
2691func TestPrinterPrintAltForeach(t *testing.T) {
2692 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…