MCPcopy
hub / github.com/valyala/quicktemplate / TestParseFuncDefSuccess

Function TestParseFuncDefSuccess

parser/functype_test.go:82–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestParseFuncDefSuccess(t *testing.T) {
83 // private func without args
84 testParseFuncDefSuccess(t, "xx()", "xx() string",
85 "streamxx(qw422016 *qt422016.Writer)", "streamxx(qw422016)",
86 "writexx(qq422016 qtio422016.Writer)", "writexx(qq422016)")
87
88 // public func with a single arg
89 testParseFuncDefSuccess(t, "F(a int)", "F(a int) string",
90 "StreamF(qw422016 *qt422016.Writer, a int)", "StreamF(qw422016, a)",
91 "WriteF(qq422016 qtio422016.Writer, a int)", "WriteF(qq422016, a)")
92
93 // public method without args
94 testParseFuncDefSuccess(t, "(f *foo) M()", "(f *foo) M() string",
95 "(f *foo) StreamM(qw422016 *qt422016.Writer)", "f.StreamM(qw422016)",
96 "(f *foo) WriteM(qq422016 qtio422016.Writer)", "f.WriteM(qq422016)")
97
98 // private method with three args
99 testParseFuncDefSuccess(t, "(f *Foo) bar(x, y string, z int)", "(f *Foo) bar(x, y string, z int) string",
100 "(f *Foo) streambar(qw422016 *qt422016.Writer, x, y string, z int)", "f.streambar(qw422016, x, y, z)",
101 "(f *Foo) writebar(qq422016 qtio422016.Writer, x, y string, z int)", "f.writebar(qq422016, x, y, z)")
102
103 // method with complex args
104 testParseFuncDefSuccess(t, "(t TPL) Head(h1, h2 func(x, y int), h3 map[int]struct{})", "(t TPL) Head(h1, h2 func(x, y int), h3 map[int]struct{}) string",
105 "(t TPL) StreamHead(qw422016 *qt422016.Writer, h1, h2 func(x, y int), h3 map[int]struct{})", "t.StreamHead(qw422016, h1, h2, h3)",
106 "(t TPL) WriteHead(qq422016 qtio422016.Writer, h1, h2 func(x, y int), h3 map[int]struct{})", "t.WriteHead(qq422016, h1, h2, h3)")
107
108 // method with variadic arguments
109 testParseFuncDefSuccess(t, "(t TPL) Head(name string, num int, otherNames ...string)", "(t TPL) Head(name string, num int, otherNames ...string) string",
110 "(t TPL) StreamHead(qw422016 *qt422016.Writer, name string, num int, otherNames ...string)", "t.StreamHead(qw422016, name, num, otherNames...)",
111 "(t TPL) WriteHead(qq422016 qtio422016.Writer, name string, num int, otherNames ...string)", "t.WriteHead(qq422016, name, num, otherNames...)")
112}
113
114func TestParseFuncDefFailure(t *testing.T) {
115 testParseFuncDefFailure(t, "")

Callers

nothing calls this directly

Calls 1

testParseFuncDefSuccessFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…