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

Function TestPrintAltWhile

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

Source from the content-addressed store, hash-verified

2336}
2337
2338func TestPrintAltWhile(t *testing.T) {
2339 o := bytes.NewBufferString("")
2340
2341 p := printer.NewPrettyPrinter(o, " ")
2342 p.Print(&stmt.Namespace{
2343 Stmts: []node.Node{
2344 &stmt.AltWhile{
2345 Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
2346 Stmt: &stmt.StmtList{
2347 Stmts: []node.Node{
2348 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
2349 },
2350 },
2351 },
2352 },
2353 })
2354
2355 expected := `namespace {
2356 while ($a) :
2357 $b;
2358 endwhile;
2359}`
2360 actual := o.String()
2361
2362 if expected != actual {
2363 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2364 }
2365}
2366
2367func TestPrintStmtBreak(t *testing.T) {
2368 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…