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

Function TestPrinterPrintStmtFor

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

Source from the content-addressed store, hash-verified

3534}
3535
3536func TestPrinterPrintStmtFor(t *testing.T) {
3537 o := bytes.NewBufferString("")
3538
3539 p := printer.NewPrinter(o)
3540 p.Print(&stmt.For{
3541 Init: []node.Node{
3542 &expr.Variable{
3543 VarName: &node.Identifier{Value: "a"},
3544 },
3545 &expr.Variable{
3546 VarName: &node.Identifier{Value: "b"},
3547 },
3548 },
3549 Cond: []node.Node{
3550 &expr.Variable{
3551 VarName: &node.Identifier{Value: "c"},
3552 },
3553 &expr.Variable{
3554 VarName: &node.Identifier{Value: "d"},
3555 },
3556 },
3557 Loop: []node.Node{
3558 &expr.Variable{
3559 VarName: &node.Identifier{Value: "e"},
3560 },
3561 &expr.Variable{
3562 VarName: &node.Identifier{Value: "f"},
3563 },
3564 },
3565 Stmt: &stmt.StmtList{
3566 Stmts: []node.Node{
3567 &stmt.Nop{},
3568 },
3569 },
3570 })
3571
3572 expected := `for($a,$b;$c,$d;$e,$f){;}`
3573 actual := o.String()
3574
3575 if expected != actual {
3576 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3577 }
3578}
3579
3580func TestPrinterPrintStmtForeach(t *testing.T) {
3581 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…