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

Function TestPrinterPrintNullable

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

Source from the content-addressed store, hash-verified

169}
170
171func TestPrinterPrintNullable(t *testing.T) {
172 o := bytes.NewBufferString("")
173
174 p := printer.NewPrinter(o)
175 p.Print(&node.Nullable{
176 Expr: &node.Parameter{
177 ByRef: true,
178 Variadic: false,
179 VariableType: &name.FullyQualified{
180 Parts: []node.Node{
181 &name.NamePart{
182 Value: "Foo",
183 },
184 },
185 },
186 Variable: &expr.Variable{
187 VarName: &node.Identifier{
188 Value: "var",
189 },
190 },
191 DefaultValue: &scalar.String{
192 Value: "'default'",
193 },
194 },
195 })
196
197 expected := "?\\Foo&$var='default'"
198 actual := o.String()
199
200 if expected != actual {
201 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
202 }
203}
204
205func TestPrinterPrintArgument(t *testing.T) {
206 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…