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

Function TestDeclsErrors

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

Source from the content-addressed store, hash-verified

250}
251
252func TestDeclsErrors(t *testing.T) {
253 tests := []struct {
254 desc string
255 input Package
256 want []ast.Decl
257 }{
258 {
259 desc: "Use has name descr atom with wrong type",
260 input: Package{
261 Name: "foo.bar",
262 units: []parse.SourceUnit{
263 {
264 Decls: []ast.Decl{
265 makeDecl(t, ast.NewAtom("Use"), []ast.Atom{ast.NewAtom("name", ast.Number(1))}, nil, nil),
266 },
267 },
268 },
269 },
270 },
271 {
272 desc: "Use has atom with unexpected args length",
273 input: Package{
274 Name: "foo.bar",
275 units: []parse.SourceUnit{
276 {
277 Decls: []ast.Decl{
278 makeDecl(t, ast.NewAtom("Use"), []ast.Atom{{ast.PredicateSym{Symbol: "name", Arity: 1}, []ast.BaseTerm{}}}, nil, nil),
279 },
280 },
281 },
282 },
283 },
284 {
285 desc: "Bound uses package but there is no Use Decl",
286 input: Package{
287 Name: "foo.bar",
288 units: []parse.SourceUnit{
289 {
290 Decls: []ast.Decl{
291 makeDecl(t, ast.NewAtom("some_decl_with_bound"), nil,
292 []ast.BoundDecl{{Bounds: []ast.BaseTerm{ast.String("package.id")}}}, nil),
293 },
294 },
295 },
296 },
297 },
298 {
299 desc: "Used package is the same current package",
300 input: Package{
301 Name: "foo.bar",
302 units: []parse.SourceUnit{
303 {
304 Decls: []ast.Decl{
305 makeDecl(t, ast.NewAtom("Use"), []ast.Atom{ast.NewAtom("name", ast.String("foo.bar"))}, nil, nil),
306 },
307 },
308 },
309 },

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected