(t *testing.T)
| 2290 | } |
| 2291 | |
| 2292 | func TestPrinterPrintExprShortArray(t *testing.T) { |
| 2293 | o := bytes.NewBufferString("") |
| 2294 | |
| 2295 | p := printer.NewPrinter(o) |
| 2296 | p.Print(&expr.ShortArray{ |
| 2297 | Items: []node.Node{ |
| 2298 | &expr.ArrayItem{ |
| 2299 | Key: &scalar.String{Value: "'Hello'"}, |
| 2300 | Val: &expr.Variable{ |
| 2301 | VarName: &node.Identifier{Value: "world"}, |
| 2302 | }, |
| 2303 | }, |
| 2304 | &expr.ArrayItem{ |
| 2305 | Key: &scalar.Lnumber{Value: "2"}, |
| 2306 | Val: &expr.Reference{Variable: &expr.Variable{ |
| 2307 | VarName: &node.Identifier{Value: "var"}, |
| 2308 | }}, |
| 2309 | }, |
| 2310 | &expr.ArrayItem{ |
| 2311 | Val: &expr.Variable{ |
| 2312 | VarName: &node.Identifier{Value: "var"}, |
| 2313 | }, |
| 2314 | }, |
| 2315 | }, |
| 2316 | }) |
| 2317 | |
| 2318 | expected := `['Hello'=>$world,2=>&$var,$var]` |
| 2319 | actual := o.String() |
| 2320 | |
| 2321 | if expected != actual { |
| 2322 | t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | func TestPrinterPrintShortList(t *testing.T) { |
| 2327 | o := bytes.NewBufferString("") |
nothing calls this directly
no test coverage detected
searching dependent graphs…