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

Function TestPrinterPrintStmtCatch

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

Source from the content-addressed store, hash-verified

2897}
2898
2899func TestPrinterPrintStmtCatch(t *testing.T) {
2900 o := bytes.NewBufferString("")
2901
2902 p := printer.NewPrinter(o)
2903 p.Print(&stmt.Catch{
2904 Types: []node.Node{
2905 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Exception"}}},
2906 &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "RuntimeException"}}},
2907 },
2908 Variable: &expr.Variable{
2909 VarName: &node.Identifier{Value: "e"},
2910 },
2911 Stmts: []node.Node{
2912 &stmt.Expression{Expr: &expr.Variable{
2913 VarName: &node.Identifier{Value: "a"},
2914 }},
2915 },
2916 })
2917
2918 expected := `catch(Exception|\RuntimeException$e){$a;}`
2919 actual := o.String()
2920
2921 if expected != actual {
2922 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2923 }
2924}
2925
2926func TestPrinterPrintStmtClassMethod(t *testing.T) {
2927 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…