Add Licensing and Contributing
[sheep] / src / test / failures.lisp
1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3.  See distributed LICENSE.txt.
2 (in-package #:sheep-test)
3
4 (let
5  ((long-line (format nil "~A~A"
6               "This second section uses PATH and X as something we should talk about, "
7               "but doesn't use all the arguments (let's include PATH here for fun)")))
8  (deffailure-func-test
9   "Long line"
10   (format nil "UNUSED => RESULT
11
12 ARGUMENTS AND VALUES:
13
14   RESULT: a pathname
15
16 DESCRIPTION:
17
18   ~A"
19    long-line)
20   (format nil "Longer than 120 chars:   ~A" long-line)))
21
22 (deffailure-func-test
23  "Blank line - after args and vals"
24  "UNUSED => RESULT
25
26 ARGUMENTS AND VALUES:
27   RESULT: a pathname
28
29 DESCRIPTION:
30
31 "
32  "Expected blank line after: ARGUMENTS AND VALUES:")
33
34 (deffailure-func-test
35  "Blank line - after description"
36  "UNUSED => RESULT
37
38 ARGUMENTS AND VALUES:
39
40   RESULT: a pathname
41
42 DESCRIPTION:
43   Fail here
44
45 "
46  "Expected blank line after: DESCRIPTION:")
47
48 (deffailure-func-test
49  "Blank line - after examples"
50  "UNUSED => RESULT
51
52 ARGUMENTS AND VALUES:
53
54   RESULT: a pathname
55
56 DESCRIPTION:
57
58   Fail here
59
60 EXAMPLES:
61   Fail here
62
63 "
64  "Expected blank line after: EXAMPLES:")
65
66 (deffailure-func-test
67  "Blank line - after header"
68  "UNUSED => RESULT
69  Fail here
70 "
71  "Expected blank line after: UNUSED => RESULT")
72
73 (deffailure-func-test
74  "Two spaces - beginning of types"
75  "UNUSED => RESULT
76
77   RESULT: RESULT1
78    RESULT1: NOT-HERE
79 "
80  "Type line did not match \"  TYPE: type-definition\":    RESULT1: NOT-HERE")
81
82 (deffailure-func-test
83  "Two spaces - beginning of args and values"
84  "UNUSED => RESULT
85
86 ARGUMENTS AND VALUES:
87
88    RESULT: fail here
89 "
90  "Argument line did not match \"  TYPE: desc\":    RESULT: fail here")
91
92 (deffailure-func-test
93  "Two spaces - in description"
94  "UNUSED => RESULT
95
96 ARGUMENTS AND VALUES:
97
98   RESULT: a result
99
100 DESCRIPTION:
101
102   This is a description
103
104   About some
105    things"
106  "Got unexpected line, requires blank lines or start with two spaces: \"   things\"")
107
108 (deffailure-func-test
109  "Two spaces - in examples"
110  "UNUSED => RESULT
111
112 ARGUMENTS AND VALUES:
113
114   RESULT: a result
115
116 DESCRIPTION:
117
118   This is a description
119
120 EXAMPLES:
121
122   (example1) => (yo)
123    (example2) => (yoyo)"
124  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
125
126 (deffailure-func-test
127  "Two spaces - in examples"
128  "UNUSED => RESULT
129
130 ARGUMENTS AND VALUES:
131
132   RESULT: a result
133
134 DESCRIPTION:
135
136   This is a description
137
138 EXAMPLES:
139
140   (example1) => (yo)
141    (example2) => (yoyo)"
142  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
143
144 (deffailure-func-test
145  "Bad type - lowercase symbol"
146  "UNUSED => REsULT
147
148   RESULT: RESULT1
149
150 "
151  "Result in UNUSED should be all upper case: REsULT")
152
153 (deffailure-func-test
154  "Bad type - or type with list"
155  "UNUSED => RESULT
156
157   RESULT: RESULT1 | (RESULT2 :success)
158
159 "
160  "Or types can't have lists in them: RESULT1 | (RESULT2 :success)")
161
162 (deffailure-func-test
163  "Bad type - or type with no space before pipe"
164  "UNUSED => RESULT
165
166   RESULT: RESULT1| RESULT2
167
168 "
169  "All or pipes must be prefaced by spaces: RESULT1| RESULT2")
170
171 (deffailure-func-test
172  "Bad type - or type with no space after pipe"
173  "UNUSED => RESULT
174
175   RESULT: RESULT1 |RESULT2
176
177 "
178  "All or pipes must be concluded by spaces: RESULT1 |RESULT2")
179
180 (deffailure-func-test
181  "Bad type - list separated by multiple spaces"
182  "UNUSED => RESULT
183
184   RESULT: (RESULT1  :success)
185
186 "
187  "Lists can be seperated by only one space: (RESULT1  :success)")
188
189 (deffailure-func-test
190  "Bad type - list parens in them"
191  "UNUSED => RESULT
192
193   RESULT: (RESULT1 (:success))
194
195 "
196  "List types can't have sublists: (RESULT1 (:success))")
197
198 (deffailure-func-test
199  "Bad type - type line doesn't have colon"
200  "UNUSED => RESULT
201
202   RESULT - RESULT1
203
204 "
205  "Type line did not match \"  TYPE: type-definition\":   RESULT - RESULT1")
206
207 (deffailure-func-test
208  "Bad type - malformed type line with colon"
209  "UNUSED => RESULT
210
211   RESULT: RESULT1 RESULT2
212
213 "
214  "Symbols had spaces in it: RESULT1 RESULT2")
215
216 (deffailure-func-test
217  "types in type section that isn't in document"
218  "UNUSED => RESULT
219
220   RESULT: RESULT1
221   RESULT2: RESULT3
222
223 "
224  "Ran out of types to talk about, but got a non empty line:   RESULT2: RESULT3")
225
226 (deffailure-func-test
227  "Description - ends with empty line when last thing"
228  "UNUSED => RESULT
229
230 ARGUMENTS AND VALUES:
231
232   RESULT: a pathname
233
234 DESCRIPTION:
235
236   Hello world
237
238 "
239  "Can't end with empty line")
240
241 (deffailure-func-test
242  "Description - malformed line"
243  "UNUSED => RESULT
244
245 ARGUMENTS AND VALUES:
246
247   RESULT: a pathname
248
249 DESCRIPTION:
250
251  A mistake"
252  "Got unexpected line, requires blank lines or start with two spaces: \" A mistake\"")
253
254 (deffailure-func-test
255  "Description - section doesn't start with description"
256  "UNUSED => RESULT
257
258 ARGUMENTS AND VALUES:
259
260   RESULT: a pathname
261
262 DESCRIPTAION:
263
264 "
265  "Expected DESCRIPTION: instead of: DESCRIPTAION:")
266
267 (deffailure-func-test
268  "Examples - doesn't have arrow"
269  "UNUSED => RESULT
270
271 ARGUMENTS AND VALUES:
272
273   RESULT: a pathname
274
275 DESCRIPTION:
276
277   This is a mock description.
278
279 EXAMPLES:
280
281   (unused) - :success
282 "
283  "Example line does not match \"  example => result\":   (unused) - :success")
284
285 (deffailure-func-test
286  "Examples - doesn't start with EXAMPLES"
287  "UNUSED => RESULT
288
289 ARGUMENTS AND VALUES:
290
291   RESULT: a pathname
292
293 DESCRIPTION:
294
295   This is a mock description.
296
297 EXAAMPLES:
298
299   (unused) => :success"
300  "Got unexpected line, requires blank lines or start with two spaces: \"EXAAMPLES:\"")
301
302 (deffailure-func-test
303  "Args-and-values - leftover unexplained args"
304  "UNUSED => RESULT
305
306   RESULT: RESULT1 | RESULT2
307
308 ARGUMENTS AND VALUES:
309
310   RESULT1: a pathname
311 "
312  "Unexplained arguments left: (RESULT2)")
313
314 (deffailure-func-test
315  "Args-and-values - doesn't match TYPE: desc"
316  "UNUSED => RESULT
317
318 ARGUMENTS AND VALUES:
319
320   RESULT - a pathname
321
322 DESCRIPTION:
323
324 "
325  "Argument line did not match \"  TYPE: desc\":   RESULT - a pathname")
326
327 (deffailure-func-test
328  "Args-and-values - section doesn't start with ARGUMENTS AND VALUES:"
329  "UNUSED => RESULT
330
331   RESULT: RESULT1
332
333 ARGUUMENTS AND VALUES:
334
335   RESULT: a pathname
336
337 DESCRIPTION:
338
339 "
340  "Expected ARGUMENTS AND VALUES: instead of: ARGUUMENTS AND VALUES:")
341
342 (deffailure-func-test
343  "Header - first line doesn't start with func-name (naturally all in upper case)"
344  "UNUUSED => RESULT
345
346 ARGUMENTS AND VALUES:
347
348   RESULT: a pathname
349
350 DESCRIPTION:
351
352 "
353  "First line of UNUSED did not match: UNUSED {ARGS}* => {RESULT}*, UNUUSED => RESULT")
354
355 (deffailure-func-test
356  "Header - arguments weren't in upper cse"
357  "UNUSED x => RESULT
358
359 ARGUMENTS AND VALUES:
360
361   RESULT: a pathname
362
363 DESCRIPTION:
364
365 "
366  "Argument in UNUSED should be all upper case: \"x\"")
367
368 (deffailure-func-test
369  "Header - results weren't in upper case"
370  "UNUSED => REsULT
371
372 ARGUMENTS AND VALUES:
373
374   RESULT: a pathname
375
376 DESCRIPTION:
377
378 "
379  "Result in UNUSED should be all upper case: REsULT")
380
381 (deffailure-var-test
382  "Blank line - after value type"
383  "*UNUSED*
384
385 VALUE TYPE:
386   generalized boolean
387
388 INITIAL VALUE:
389
390   NIL
391
392 DESCRIPTION:
393
394 "
395  "Expected blank line after: VALUE TYPE:")
396
397 (deffailure-var-test
398  "Blank line - after description"
399  "*UNUSED*
400
401 VALUE TYPE:
402
403   generalized boolean
404
405 INITIAL VALUE:
406
407   NIL
408
409 DESCRIPTION:
410   Fail here
411
412 "
413  "Expected blank line after: DESCRIPTION:")
414
415 (deffailure-var-test
416  "Blank line - after examples"
417  "*UNUSED*
418
419 VALUE TYPE:
420
421   generalized boolean
422
423 INITIAL VALUE:
424
425   NIL
426
427 DESCRIPTION:
428
429   Fail here
430
431 EXAMPLES:
432   Fail here
433
434 "
435  "Expected blank line after: EXAMPLES:")
436
437 (deffailure-var-test
438  "Blank line - after header"
439  "*UNUSED*
440  Fail here
441 "
442  "Expected blank line after: *UNUSED*")
443
444 (deffailure-var-test
445  "Two spaces - beginning of value type"
446  "*UNUSED*
447
448 VALUE TYPE:
449
450    a generalized boolean
451 "
452  "Got unexpected line, requires blank lines or start with two spaces: \"   a generalized boolean\"")
453
454 (deffailure-var-test
455  "Two spaces - beginning of initial value"
456  "*UNUSED*
457
458 VALUE TYPE:
459
460   a generalized boolean
461
462 INITIAL VALUE:
463
464    RESULT: fail here
465 "
466  "Got unexpected line, requires blank lines or start with two spaces: \"   RESULT: fail here\"")
467
468 (deffailure-var-test
469  "Two spaces - in description"
470  "*UNUSED*
471
472 VALUE TYPE:
473
474   a generalized boolean
475
476 INITIAL VALUE:
477
478   RESULT: a result
479
480 DESCRIPTION:
481
482   This is a description
483
484   About some
485    things"
486  "Got unexpected line, requires blank lines or start with two spaces: \"   things\"")
487
488 (deffailure-var-test
489  "Two spaces - in examples"
490  "*UNUSED*
491
492 VALUE TYPE:
493
494   a generalized boolean
495
496 INITIAL VALUE:
497
498   RESULT: a result
499
500 DESCRIPTION:
501
502   This is a description
503
504 EXAMPLES:
505
506   (example1) => (yo)
507    (example2) => (yoyo)"
508  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
509
510 (deffailure-var-test
511  "Two spaces - in examples"
512  "*UNUSED*
513
514 VALUE TYPE:
515
516   a generalized boolean
517
518 INITIAL VALUE:
519
520   RESULT: a result
521
522 DESCRIPTION:
523
524   This is a description
525
526 EXAMPLES:
527
528   (example1) => (yo)
529    (example2) => (yoyo)"
530  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
531
532 (deffailure-var-test
533  "Description - ends with empty line when last thing"
534  "*UNUSED*
535
536 VALUE TYPE:
537
538   a generalized boolean
539
540 INITIAL VALUE:
541
542   NIL
543
544 DESCRIPTION:
545
546   Hello world
547
548 "
549  "Can't end with empty line")
550
551 (deffailure-var-test
552  "Description - malformed line"
553  "*UNUSED*
554
555 VALUE TYPE:
556
557   a generalized boolean
558
559 INITIAL VALUE:
560
561   NIL
562
563 DESCRIPTION:
564
565  A mistake"
566  "Got unexpected line, requires blank lines or start with two spaces: \" A mistake\"")
567
568 (deffailure-var-test
569  "Description - section doesn't start with description"
570  "*UNUSED*
571
572 VALUE TYPE:
573
574   a generalized boolean
575
576 INITIAL VALUE:
577
578   NIL
579
580 DESCRIPTAION:
581
582 "
583  "Got unexpected line, requires blank lines or start with two spaces: \"DESCRIPTAION:\"")
584
585 (deffailure-var-test
586  "Examples - doesn't have arrow"
587  "*UNUSED*
588
589 VALUE TYPE:
590
591   a generalized boolean
592
593 INITIAL VALUE:
594
595   NIL
596
597 DESCRIPTION:
598
599   This is a mock description.
600
601 EXAMPLES:
602
603   *unused* - :success
604 "
605  "Example line does not match \"  example => result\":   *unused* - :success")
606
607 (deffailure-var-test
608  "Examples - doesn't start with EXAMPLES"
609  "*UNUSED*
610
611 VALUE TYPE:
612
613   a generalized boolean
614
615 INITIAL VALUE:
616
617   NIL
618
619 DESCRIPTION:
620
621   This is a mock description.
622
623 EXAAMPLES:
624
625   *unused* => :success"
626  "Got unexpected line, requires blank lines or start with two spaces: \"EXAAMPLES:\"")
627
628 (deffailure-var-test
629  "Header - first line doesn't start with var-name (naturally all in upper case)"
630  "*UNUUSED*
631
632 INITIAL VALUE:
633
634   RESULT: a pathname
635
636 DESCRIPTION:
637
638 "
639  "First line of *UNUSED* did not match: *UNUSED*, *UNUUSED*")
640
641 (deffailure-var-test
642  "General - No value type"
643  "*UNUSED*
644
645 INITIAL VALUE:
646
647   NIL
648
649 DESCRIPTAION:
650
651 "
652  "Expected VALUE TYPE: instead of: INITIAL VALUE:")
653
654 (deffailure-var-test
655  "General - No initial value"
656  "*UNUSED*
657
658 VALUE TYPE:
659
660   a generalized boolean
661
662 DESCRIPTION:
663
664 "
665  "Got unexpected line, requires blank lines or start with two spaces: \"DESCRIPTION:\"")
666
667 (deffailure-var-test
668  "General - Ends early"
669  "*UNUSED*
670
671 VALUE TYPE:
672
673   a generalized boolean"
674  "Got unexpected line, requires blank lines or start with two spaces: NIL")