(t *testing.T)
| 2720 | } |
| 2721 | |
| 2722 | func TestPrinterPrintAltIf(t *testing.T) { |
| 2723 | o := bytes.NewBufferString("") |
| 2724 | |
| 2725 | p := printer.NewPrinter(o) |
| 2726 | p.Print(&stmt.AltIf{ |
| 2727 | Cond: &expr.Variable{ |
| 2728 | VarName: &node.Identifier{Value: "a"}, |
| 2729 | }, |
| 2730 | Stmt: &stmt.StmtList{ |
| 2731 | Stmts: []node.Node{ |
| 2732 | &stmt.Expression{Expr: &expr.Variable{ |
| 2733 | VarName: &node.Identifier{Value: "d"}, |
| 2734 | }}, |
| 2735 | }, |
| 2736 | }, |
| 2737 | ElseIf: []node.Node{ |
| 2738 | &stmt.AltElseIf{ |
| 2739 | Cond: &expr.Variable{ |
| 2740 | VarName: &node.Identifier{Value: "b"}, |
| 2741 | }, |
| 2742 | Stmt: &stmt.StmtList{ |
| 2743 | Stmts: []node.Node{ |
| 2744 | &stmt.Expression{Expr: &expr.Variable{ |
| 2745 | VarName: &node.Identifier{Value: "b"}, |
| 2746 | }}, |
| 2747 | }, |
| 2748 | }, |
| 2749 | }, |
| 2750 | &stmt.AltElseIf{ |
| 2751 | Cond: &expr.Variable{ |
| 2752 | VarName: &node.Identifier{Value: "c"}, |
| 2753 | }, |
| 2754 | Stmt: &stmt.StmtList{}, |
| 2755 | }, |
| 2756 | }, |
| 2757 | Else: &stmt.AltElse{ |
| 2758 | Stmt: &stmt.StmtList{ |
| 2759 | Stmts: []node.Node{ |
| 2760 | &stmt.Expression{Expr: &expr.Variable{ |
| 2761 | VarName: &node.Identifier{Value: "b"}, |
| 2762 | }}, |
| 2763 | }, |
| 2764 | }, |
| 2765 | }, |
| 2766 | }) |
| 2767 | |
| 2768 | expected := `if($a):$d;elseif($b):$b;elseif($c):else:$b;endif;` |
| 2769 | actual := o.String() |
| 2770 | |
| 2771 | if expected != actual { |
| 2772 | t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) |
| 2773 | } |
| 2774 | } |
| 2775 | |
| 2776 | func TestPrinterPrintStmtAltSwitch(t *testing.T) { |
| 2777 | o := bytes.NewBufferString("") |
nothing calls this directly
no test coverage detected
searching dependent graphs…