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

Function TestPrintWhileExpression

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

Source from the content-addressed store, hash-verified

4061}
4062
4063func TestPrintWhileExpression(t *testing.T) {
4064 o := bytes.NewBufferString("")
4065
4066 p := printer.NewPrettyPrinter(o, " ")
4067 p.Print(&stmt.Namespace{
4068 Stmts: []node.Node{
4069 &stmt.While{
4070 Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
4071 Stmt: &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
4072 },
4073 },
4074 })
4075
4076 expected := `namespace {
4077 while ($a)
4078 $a;
4079}`
4080 actual := o.String()
4081
4082 if expected != actual {
4083 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
4084 }
4085}
4086
4087func TestPrintWhileNop(t *testing.T) {
4088 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…