1
0
mirror of synced 2026-05-03 14:49:45 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/6-2-2-NULL.TEST

62 lines
1.6 KiB
Plaintext

;; Function To Be Tested: null
;;
;; Source: CLtL p. 73
;;
;; Chapter 6: Predicates Section 2-2: Specific Data Type Predicates
;;
;; Created By: Peter Reidy
;;
;; Creation Date: 17 September 86
;;
;; Last Update: 15 December 86
;;
;; Filed As: {eris}<lispcore>cml>test>6-2-2-null.test
;;
;; Syntax: null object
;;
;; Function Description: Returns non-nil iff object is NIL (the empty list), and NIL otherwise. Equivalent to the predicate not.
;;
;; Argument(s): object any cml object
;;
;; Returns: non-nil or NIL
;;
(do-test-group null-group
:before
(test-defun nulltest (object)
"True cases of NULL return non-nil, others NIL."
(cond
((not (null expected-value))
(not (null (consp object))))
(t (eq nil (consp object)))
) ; cond
;; For null or non-null object, test the equivalencies in Steele's function description.
(and
(eq (null object) (typep object 'null))
(eq (null object) (eq object '()))
(eq (null object) (not object))
(eq (typep object 'null) (eq object '()))
;; See that (null object) has the expected truth value.
(eq (null object) expected-value)
) ; AND
) ; test-defun
;;
(do-test null-test-with-null-objects
(let ((expected-value t))
(declare (special expected-value))
(every 'nulltest
(list nil '() (not t) nil)
) ; every
) ; let
) ; do-test
(do-test null-test-with-non-null-objects
(let ((expected-value nil))
(declare (special expected-value))
(every 'nulltest
(list t '(nil) (not nil) (sqrt pi) "nil")
) ; every
) ; let
) ; do-test
) ; do-test-group
STOP