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

Function TestPrintAltFor

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

Source from the content-addressed store, hash-verified

2170}
2171
2172func TestPrintAltFor(t *testing.T) {
2173 o := bytes.NewBufferString("")
2174
2175 p := printer.NewPrettyPrinter(o, " ")
2176 p.Print(&stmt.Namespace{
2177 Stmts: []node.Node{
2178 &stmt.AltFor{
2179 Init: []node.Node{
2180 &expr.Variable{VarName: &node.Identifier{Value: "a"}},
2181 },
2182 Cond: []node.Node{
2183 &expr.Variable{VarName: &node.Identifier{Value: "b"}},
2184 },
2185 Loop: []node.Node{
2186 &expr.Variable{VarName: &node.Identifier{Value: "c"}},
2187 },
2188 Stmt: &stmt.StmtList{
2189 Stmts: []node.Node{
2190 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}},
2191 },
2192 },
2193 },
2194 },
2195 })
2196
2197 expected := `namespace {
2198 for ($a; $b; $c) :
2199 $d;
2200 endfor;
2201}`
2202 actual := o.String()
2203
2204 if expected != actual {
2205 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2206 }
2207}
2208
2209func TestPrintAltForeach(t *testing.T) {
2210 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…