| 212 | } |
| 213 | |
| 214 | func TestDescrCheckingNegative(t *testing.T) { |
| 215 | tests := []struct { |
| 216 | name string |
| 217 | descrAtoms []ast.Atom |
| 218 | }{ |
| 219 | { |
| 220 | name: "empty doc atom", |
| 221 | descrAtoms: []ast.Atom{ast.NewAtom("doc"), argAtomBar, argAtomBaz}, |
| 222 | }, |
| 223 | { |
| 224 | name: "bad doc atom", |
| 225 | descrAtoms: []ast.Atom{ast.NewAtom("doc", ast.Number(42)), argAtomBar, argAtomBaz}, |
| 226 | }, |
| 227 | { |
| 228 | name: "missing argdoc", |
| 229 | descrAtoms: []ast.Atom{docAtomOne, argAtomBar}, |
| 230 | }, |
| 231 | { |
| 232 | name: "too many argdoc", |
| 233 | descrAtoms: []ast.Atom{docAtomOne, argAtomBar, argAtomBaz, argAtomBaz}, |
| 234 | }, |
| 235 | { |
| 236 | name: "wrong argdoc", |
| 237 | descrAtoms: []ast.Atom{ |
| 238 | docAtomOne, |
| 239 | argAtomBar, |
| 240 | ast.NewAtom("arg", ast.Variable{"Wrong"}, ast.String("an arg docu for Wrong")), |
| 241 | }, |
| 242 | }, |
| 243 | } |
| 244 | |
| 245 | for _, test := range tests { |
| 246 | t.Run(test.name, func(t *testing.T) { |
| 247 | c := newDeclChecker(mustDecl(test.descrAtoms, nil, nil)) |
| 248 | if errs := c.check(); errs == nil { |
| 249 | t.Errorf("%s: expected error for %+v", test.name, c.decl) |
| 250 | } |
| 251 | }) |
| 252 | } |
| 253 | } |