MCPcopy
hub / github.com/google/mangle / TestDecls

Function TestDecls

packages/packages_test.go:148–250  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestDecls(t *testing.T) {
149 tests := []struct {
150 desc string
151 input Package
152 want []ast.Decl
153 }{
154 {
155 desc: "no package name, declarations are returned as is",
156 input: Package{
157 Name: "",
158 units: []parse.SourceUnit{
159 {
160 Decls: []ast.Decl{
161 makeDecl(t, ast.NewAtom("some_decl"), nil, nil, nil),
162 },
163 },
164 {
165 Decls: []ast.Decl{
166 makeDecl(t, ast.NewAtom("some_decl_in_another_unit"), nil, nil, nil),
167 },
168 },
169 },
170 },
171 want: []ast.Decl{
172 makeDecl(t, ast.NewAtom("some_decl"), nil, nil, nil),
173 makeDecl(t, ast.NewAtom("some_decl_in_another_unit"), nil, nil, nil),
174 },
175 },
176 {
177 desc: "has package name, declarations are prefixed",
178 input: Package{
179 Name: "foo.bar",
180 units: []parse.SourceUnit{
181 {
182 Decls: []ast.Decl{
183 makeDecl(t, ast.NewAtom("some_decl"), nil, nil, nil),
184 },
185 },
186 {
187 Decls: []ast.Decl{
188 makeDecl(t, ast.NewAtom("some_decl_in_another_unit"), nil, nil, nil),
189 },
190 },
191 },
192 },
193 want: []ast.Decl{
194 makeDecl(t, ast.NewAtom("foo.bar.some_decl"), nil, nil, nil),
195 makeDecl(t, ast.NewAtom("foo.bar.some_decl_in_another_unit"), nil, nil, nil),
196 },
197 },
198 {
199 desc: "bound uses declared decl",
200 input: Package{
201 Name: "foo.bar",
202 units: []parse.SourceUnit{
203 {
204 Decls: []ast.Decl{
205 makeDecl(t, ast.NewAtom("some_decl", ast.Variable{"X"}), nil, nil, nil),

Callers

nothing calls this directly

Calls 4

NewAtomFunction · 0.92
StringFunction · 0.92
DeclsMethod · 0.80
makeDeclFunction · 0.70

Tested by

no test coverage detected