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

Function TestPrinterPrintStmtAltSwitch

printer/printer_test.go:2776–2812  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2774}
2775
2776func TestPrinterPrintStmtAltSwitch(t *testing.T) {
2777 o := bytes.NewBufferString("")
2778
2779 p := printer.NewPrinter(o)
2780 p.Print(&stmt.AltSwitch{
2781 Cond: &expr.Variable{
2782 VarName: &node.Identifier{Value: "var"},
2783 },
2784 CaseList: &stmt.CaseList{
2785 Cases: []node.Node{
2786 &stmt.Case{
2787 Cond: &scalar.String{Value: "'a'"},
2788 Stmts: []node.Node{
2789 &stmt.Expression{Expr: &expr.Variable{
2790 VarName: &node.Identifier{Value: "a"},
2791 }},
2792 },
2793 },
2794 &stmt.Case{
2795 Cond: &scalar.String{Value: "'b'"},
2796 Stmts: []node.Node{
2797 &stmt.Expression{Expr: &expr.Variable{
2798 VarName: &node.Identifier{Value: "b"},
2799 }},
2800 },
2801 },
2802 },
2803 },
2804 })
2805
2806 expected := `switch($var):case 'a':$a;case 'b':$b;endswitch;`
2807 actual := o.String()
2808
2809 if expected != actual {
2810 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2811 }
2812}
2813
2814func TestPrinterPrintAltWhile(t *testing.T) {
2815 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…