Add coverage, get to near 100
[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  "Args-and-values - non empty next line"
344  "UNUSED => RESULT
345
346 ARGUMENTS AND VALUES:
347
348   RESULT: a pathname
349   RESULT2: a thing
350
351 DESCRIPTION:
352
353 "
354  "No arguments left, but next line isn't empty:   RESULT2: a thing")
355
356 (deffailure-func-test
357  "Args-and-values - out of order arguments"
358  "UNUSED => RESULT1, RESULT2
359
360 ARGUMENTS AND VALUES:
361
362   RESULT2: a thing
363   RESULT1: a thing
364
365 DESCRIPTION:
366
367 "
368  "Expected a description for RESULT1 but got one for RESULT2")
369
370 (deffailure-func-test
371  "Args-and-values - ended before all arguments"
372  "UNUSED => RESULT1, RESULT2
373
374 ARGUMENTS AND VALUES:
375
376   RESULT1: a thing"
377  "Expected line after:   RESULT1: a thing")
378
379 (deffailure-func-test
380  "Header - first line doesn't start with func-name (naturally all in upper case)"
381  "UNUUSED => RESULT
382
383 ARGUMENTS AND VALUES:
384
385   RESULT: a pathname
386
387 DESCRIPTION:
388
389 "
390  "First line of UNUSED did not match: UNUSED {ARGS}* => {RESULT}*, UNUUSED => RESULT")
391
392 (deffailure-func-test
393  "Header - arguments weren't in upper cse"
394  "UNUSED x => RESULT
395
396 ARGUMENTS AND VALUES:
397
398   RESULT: a pathname
399
400 DESCRIPTION:
401
402 "
403  "Argument in UNUSED should be all upper case: \"x\"")
404
405 (deffailure-func-test
406  "Header - results weren't in upper case"
407  "UNUSED => REsULT
408
409 ARGUMENTS AND VALUES:
410
411   RESULT: a pathname
412
413 DESCRIPTION:
414
415 "
416  "Result in UNUSED should be all upper case: REsULT")
417
418 (deffailure-func-test
419  "Description - can't end line with space"
420  "UNUSED => RESULT
421
422 ARGUMENTS AND VALUES:
423
424   RESULT: a pathname
425
426 DESCRIPTION:
427
428   This is a test 
429 "
430  "Can't end line with a space:   This is a test ")
431
432 (deffailure-func-test
433  "Symbols - keyword symbols must be all in lower case"
434  "UNUSED => RESULT
435
436   RESULT: (:ASDF)
437
438 DESCRIPTION:
439
440   This is a test 
441 "
442  "Keyword symbols must all be lower case: :ASDF")
443
444 (deffailure-func-test
445  "Symbols - type symbols must be all in lower case"
446  "UNUSED => RESULT
447
448   RESULT: (asdf)
449
450 DESCRIPTION:
451
452   This is a test 
453 "
454  "Type symbols must all be upper case: asdf")
455
456 (deffailure-func-test
457  "Symbols - list types can't have | in them"
458  "UNUSED => RESULT
459
460   RESULT: (ASDF | FDSA)
461
462 DESCRIPTION:
463
464   This is a test 
465 "
466  "List types can't have | in them: (ASDF | FDSA)")
467
468 (deffailure-var-test
469  "Blank line - after value type"
470  "*UNUSED*
471
472 VALUE TYPE:
473   generalized boolean
474
475 INITIAL VALUE:
476
477   NIL
478
479 DESCRIPTION:
480
481 "
482  "Expected blank line after: VALUE TYPE:")
483
484 (deffailure-var-test
485  "Blank line - after description"
486  "*UNUSED*
487
488 VALUE TYPE:
489
490   generalized boolean
491
492 INITIAL VALUE:
493
494   NIL
495
496 DESCRIPTION:
497   Fail here
498
499 "
500  "Expected blank line after: DESCRIPTION:")
501
502 (deffailure-var-test
503  "Blank line - after examples"
504  "*UNUSED*
505
506 VALUE TYPE:
507
508   generalized boolean
509
510 INITIAL VALUE:
511
512   NIL
513
514 DESCRIPTION:
515
516   Fail here
517
518 EXAMPLES:
519   Fail here
520
521 "
522  "Expected blank line after: EXAMPLES:")
523
524 (deffailure-var-test
525  "Blank line - after header"
526  "*UNUSED*
527  Fail here
528 "
529  "Expected blank line after: *UNUSED*")
530
531 (deffailure-var-test
532  "Two spaces - beginning of value type"
533  "*UNUSED*
534
535 VALUE TYPE:
536
537    a generalized boolean
538 "
539  "Got unexpected line, requires blank lines or start with two spaces: \"   a generalized boolean\"")
540
541 (deffailure-var-test
542  "Two spaces - beginning of initial value"
543  "*UNUSED*
544
545 VALUE TYPE:
546
547   a generalized boolean
548
549 INITIAL VALUE:
550
551    RESULT: fail here
552 "
553  "Got unexpected line, requires blank lines or start with two spaces: \"   RESULT: fail here\"")
554
555 (deffailure-var-test
556  "Two spaces - in description"
557  "*UNUSED*
558
559 VALUE TYPE:
560
561   a generalized boolean
562
563 INITIAL VALUE:
564
565   RESULT: a result
566
567 DESCRIPTION:
568
569   This is a description
570
571   About some
572    things"
573  "Got unexpected line, requires blank lines or start with two spaces: \"   things\"")
574
575 (deffailure-var-test
576  "Two spaces - in examples"
577  "*UNUSED*
578
579 VALUE TYPE:
580
581   a generalized boolean
582
583 INITIAL VALUE:
584
585   RESULT: a result
586
587 DESCRIPTION:
588
589   This is a description
590
591 EXAMPLES:
592
593   (example1) => (yo)
594    (example2) => (yoyo)"
595  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
596
597 (deffailure-var-test
598  "Two spaces - in examples"
599  "*UNUSED*
600
601 VALUE TYPE:
602
603   a generalized boolean
604
605 INITIAL VALUE:
606
607   RESULT: a result
608
609 DESCRIPTION:
610
611   This is a description
612
613 EXAMPLES:
614
615   (example1) => (yo)
616    (example2) => (yoyo)"
617  "Example line does not match \"  example => result\":    (example2) => (yoyo)")
618
619 (deffailure-var-test
620  "Description - ends with empty line when last thing"
621  "*UNUSED*
622
623 VALUE TYPE:
624
625   a generalized boolean
626
627 INITIAL VALUE:
628
629   NIL
630
631 DESCRIPTION:
632
633   Hello world
634
635 "
636  "Can't end with empty line")
637
638 (deffailure-var-test
639  "Description - malformed line"
640  "*UNUSED*
641
642 VALUE TYPE:
643
644   a generalized boolean
645
646 INITIAL VALUE:
647
648   NIL
649
650 DESCRIPTION:
651
652  A mistake"
653  "Got unexpected line, requires blank lines or start with two spaces: \" A mistake\"")
654
655 (deffailure-var-test
656  "Description - section doesn't start with description"
657  "*UNUSED*
658
659 VALUE TYPE:
660
661   a generalized boolean
662
663 INITIAL VALUE:
664
665   NIL
666
667 DESCRIPTAION:
668
669 "
670  "Got unexpected line, requires blank lines or start with two spaces: \"DESCRIPTAION:\"")
671
672 (deffailure-var-test
673  "Examples - doesn't have arrow"
674  "*UNUSED*
675
676 VALUE TYPE:
677
678   a generalized boolean
679
680 INITIAL VALUE:
681
682   NIL
683
684 DESCRIPTION:
685
686   This is a mock description.
687
688 EXAMPLES:
689
690   *unused* - :success
691 "
692  "Example line does not match \"  example => result\":   *unused* - :success")
693
694 (deffailure-var-test
695  "Examples - doesn't start with EXAMPLES"
696  "*UNUSED*
697
698 VALUE TYPE:
699
700   a generalized boolean
701
702 INITIAL VALUE:
703
704   NIL
705
706 DESCRIPTION:
707
708   This is a mock description.
709
710 EXAAMPLES:
711
712   *unused* => :success"
713  "Got unexpected line, requires blank lines or start with two spaces: \"EXAAMPLES:\"")
714
715 (deffailure-var-test
716  "Header - first line doesn't start with var-name (naturally all in upper case)"
717  "*UNUUSED*
718
719 INITIAL VALUE:
720
721   RESULT: a pathname
722
723 DESCRIPTION:
724
725 "
726  "First line of *UNUSED* did not match: *UNUSED*, *UNUUSED*")
727
728 (deffailure-var-test
729  "General - No value type"
730  "*UNUSED*
731
732 INITIAL VALUE:
733
734   NIL
735
736 DESCRIPTAION:
737
738 "
739  "Expected VALUE TYPE: instead of: INITIAL VALUE:")
740
741 (deffailure-var-test
742  "General - No initial value"
743  "*UNUSED*
744
745 VALUE TYPE:
746
747   a generalized boolean
748
749 DESCRIPTION:
750
751 "
752  "Got unexpected line, requires blank lines or start with two spaces: \"DESCRIPTION:\"")
753
754 (deffailure-var-test
755  "General - Ends early"
756  "*UNUSED*
757
758 VALUE TYPE:
759
760   a generalized boolean"
761  "Got unexpected line, requires blank lines or start with two spaces: NIL")
762
763 (deffailure-var-test
764  "General - Can't end line with a space"
765  "*UNUSED*
766
767 VALUE TYPE:
768
769   a generalized boolean
770
771 INITIAL VALUE:
772
773   NIL
774
775 DESCRIPTION:
776
777   This description line ends with a space "
778  "Can't end line with a space:   This description line ends with a space ")
779
780 (deffailure-var-test
781  "General - Longer than 120 characters"
782  (format nil "~A~A"
783   "*UNUSED*
784
785 VALUE TYPE:
786
787   a generalized boolean
788
789 INITIAL VALUE:
790
791   NIL
792
793 DESCRIPTION:
794
795   This description line ends with a space is very very long, so very long, really really long"
796   "it just keeps going and going and going and going and going and going")
797  (format nil "Longer than 120 chars:   ~A~A"
798   "This description line ends with a space is very very long, so very long, really really long"
799   "it just keeps going and going and going and going and going and going"))
800
801 (deffailure-pkg-test
802  "Line too long"
803  "Unused package with a first line that is extremely long, and how could it be so
804 long and it keeps going and going and going and going and going and going"
805  "First package paragraph is longer than 120 characters")
806
807 (deffailure-pkg-test
808  "Line too long 2"
809  (format nil "~A~A"
810   "Unused package with a first line that is extremely long, and how could it be so"
811   "long and it keeps going and going and going and going and going and going")
812  (format nil "~A~A~A"
813   "Package description longer than 120 characters: "
814   "Unused package with a first line that is extremely long, and how could it be so"
815   "long and it keeps going and going and going and going and going and going"))
816
817 (deffailure-pkg-test
818  "Two empty lines"
819  "Basic description
820
821
822 More information"
823  "Package description has two empty lines in it")
824
825 (deffailure-pkg-test
826  "Started with space"
827  " Basic Description"
828  "Package description line started with space:  Basic Description")
829
830 (deffailure-pkg-test
831  "Ended with space"
832  "Basic Description "
833  "Package description line ended with space: Basic Description ")
834
835 (deffailure-struc-test
836  "Two empty lines"
837  "Basic description
838
839
840 More information"
841  "Structure description has two empty lines in it")
842
843 (deffailure-struc-test
844  "Line too long"
845  (format nil "~A~A"
846   "Unused package with a first line that is extremely long, and how could it be so"
847   "long and it keeps going and going and going and going and going and going")
848  (format nil "~A~A~A"
849   "Structure description longer than 120 characters: "
850   "Unused package with a first line that is extremely long, and how could it be so"
851   "long and it keeps going and going and going and going and going and going"))
852
853 (deffailure-struc-test
854  "Started with space"
855  " Basic Description"
856  "Structure description line started with space:  Basic Description")
857
858 (deffailure-struc-test
859  "Ended with space"
860  "Basic Description "
861  "Structure description line ended with space: Basic Description ")