(t *testing.T)
| 3154 | } |
| 3155 | |
| 3156 | func TestPrintStmtForeachExpr(t *testing.T) { |
| 3157 | o := bytes.NewBufferString("") |
| 3158 | |
| 3159 | p := printer.NewPrettyPrinter(o, " ") |
| 3160 | p.Print(&stmt.Namespace{ |
| 3161 | Stmts: []node.Node{ |
| 3162 | &stmt.Foreach{ |
| 3163 | Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, |
| 3164 | Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, |
| 3165 | Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}, |
| 3166 | Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, |
| 3167 | }, |
| 3168 | }, |
| 3169 | }) |
| 3170 | |
| 3171 | expected := `namespace { |
| 3172 | foreach ($a as $k => $v) |
| 3173 | 'bar'; |
| 3174 | }` |
| 3175 | actual := o.String() |
| 3176 | |
| 3177 | if expected != actual { |
| 3178 | t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) |
| 3179 | } |
| 3180 | } |
| 3181 | |
| 3182 | func TestPrintStmtForeachNop(t *testing.T) { |
| 3183 | o := bytes.NewBufferString("") |
nothing calls this directly
no test coverage detected
searching dependent graphs…