-
Notifications
You must be signed in to change notification settings - Fork 0
/
FEMTOUNIT
71 lines (53 loc) · 3.19 KB
/
FEMTOUNIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
(FILECREATED "19-Mar-2024 05:21:08" {DSK}<home>medley>il>FEMTOUNIT.;14 3126
:EDIT-BY "PA"
:CHANGES-TO (FUNCTIONS DEFTEST)
:PREVIOUS-DATE "15-Sep-2023 09:02:47" {DSK}<home>medley>il>FEMTOUNIT.;13)
(PRETTYCOMPRINT FEMTOUNITCOMS)
(RPAQQ FEMTOUNITCOMS ((VARS (FTU.TEST.NAME NIL))
(FNS REPORT.RESULT)
(FUNCTIONS CHECK.EXPECT COMBINE.RESULTS DEFTEST)
(DEFINE-TYPES TESTS)
(P (SEDIT:DEF-LIST-FORMAT DEFTEST CL:DEFUN))))
(RPAQQ FTU.TEST.NAME NIL)
(DEFINEQ
(REPORT.RESULT
[LAMBDA (RESULT FORM) (* ; "Edited 3-Jun-2023 02:38 by PA")
(* ; "Edited 31-May-2023 10:27 by PA")
(* Report the results RESULT of the single test case FORM and return RESULT.
Called by CHECK.EXPECT.)
(if RESULT
then (PRIN1 ".")
else (FRESHLINE)
(PRINTOUT NIL "FAIL" %, FTU.TEST.NAME ":" %, FORM T))
RESULT])
)
(DEFMACRO CHECK.EXPECT (&BODY FORMS) (* ; "Edited 31-May-2023 11:29 by PA")
(* ;
"Run each expression in the sequence of FORMS as a test case.")
`[COMBINE.RESULTS ,@(FOR F IN FORMS COLLECT `(REPORT.RESULT ,F ',F])
(DEFMACRO COMBINE.RESULTS (&BODY FORMS &AUX (RESULT (GENSYM)))
(* ; "Edited 31-May-2023 10:22 by PA")
(* ;; "Combine the results as booleans of evaluating the sequence of FORMS in order. Similar to AND but all the forms are evaluated.")
`(LET ((,RESULT T))
,@[FOR F IN FORMS COLLECT `(IF (NOT ,F)
THEN (SETQ ,RESULT NIL]
,RESULT))
(DEFDEFINER (DEFTEST [:PROTOTYPE (LAMBDA (NAME)
(AND (LITATOM NAME)
`(DEFTEST ,NAME ("Arg List")
"Body")]) TESTS (NAME PARAMETERS &BODY BODY)
(* ; "Edited 19-Mar-2024 05:16 by PA")
(* ; "Edited 15-Sep-2023 09:02 by PA")
(* ; "Edited 6-Sep-2023 10:00 by PA")
(* ; "Edited 19-Aug-2023 04:25 by PA")
`(PROG1 (DEFINEQ (,NAME ,PARAMETERS (LET [(FTU.TEST.NAME (APPEND FTU.TEST.NAME
(LIST ',NAME]
,@BODY)))
(UNMARKASCHANGED ',NAME 'FNS)))
(DEF-DEFINE-TYPE TESTS "Femtounit unit tests")
(SEDIT:DEF-LIST-FORMAT DEFTEST CL:DEFUN)
(DECLARE%: DONTCOPY
(FILEMAP (NIL (642 1171 (REPORT.RESULT 652 . 1169)) (1173 1554 (CHECK.EXPECT 1173 . 1554)) (1556 2050
(COMBINE.RESULTS 1556 . 2050)))))
STOP