(t *testing.T)
| 4124 | } |
| 4125 | |
| 4126 | func TestPrinterPrintStmtSwitch(t *testing.T) { |
| 4127 | o := bytes.NewBufferString("") |
| 4128 | |
| 4129 | p := printer.NewPrinter(o) |
| 4130 | p.Print(&stmt.Switch{ |
| 4131 | Cond: &expr.Variable{ |
| 4132 | VarName: &node.Identifier{Value: "var"}, |
| 4133 | }, |
| 4134 | CaseList: &stmt.CaseList{ |
| 4135 | Cases: []node.Node{ |
| 4136 | &stmt.Case{ |
| 4137 | Cond: &scalar.String{Value: "'a'"}, |
| 4138 | Stmts: []node.Node{ |
| 4139 | &stmt.Expression{Expr: &expr.Variable{ |
| 4140 | VarName: &node.Identifier{Value: "a"}, |
| 4141 | }}, |
| 4142 | }, |
| 4143 | }, |
| 4144 | &stmt.Case{ |
| 4145 | Cond: &scalar.String{Value: "'b'"}, |
| 4146 | Stmts: []node.Node{ |
| 4147 | &stmt.Expression{Expr: &expr.Variable{ |
| 4148 | VarName: &node.Identifier{Value: "b"}, |
| 4149 | }}, |
| 4150 | }, |
| 4151 | }, |
| 4152 | }, |
| 4153 | }, |
| 4154 | }) |
| 4155 | |
| 4156 | expected := `switch($var){case 'a':$a;case 'b':$b;}` |
| 4157 | actual := o.String() |
| 4158 | |
| 4159 | if expected != actual { |
| 4160 | t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) |
| 4161 | } |
| 4162 | } |
| 4163 | |
| 4164 | func TestPrinterPrintStmtThrow(t *testing.T) { |
| 4165 | o := bytes.NewBufferString("") |
nothing calls this directly
no test coverage detected
searching dependent graphs…