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

Function TestPrintStmtFunction

printer/pretty_printer_test.go:3201–3235  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3199}
3200
3201func TestPrintStmtFunction(t *testing.T) {
3202 o := bytes.NewBufferString("")
3203
3204 p := printer.NewPrettyPrinter(o, " ")
3205 p.Print(&stmt.Namespace{
3206 Stmts: []node.Node{
3207 &stmt.Function{
3208 ReturnsRef: true,
3209 FunctionName: &node.Identifier{Value: "foo"},
3210 Params: []node.Node{
3211 &node.Parameter{
3212 ByRef: true,
3213 Variadic: false,
3214 Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
3215 },
3216 },
3217 ReturnType: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
3218 Stmts: []node.Node{
3219 &stmt.Nop{},
3220 },
3221 },
3222 },
3223 })
3224
3225 expected := `namespace {
3226 function &foo(&$var): \Foo {
3227 ;
3228 }
3229}`
3230 actual := o.String()
3231
3232 if expected != actual {
3233 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3234 }
3235}
3236
3237func TestPrintStmtGlobal(t *testing.T) {
3238 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrettyPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…