61 lines
1.8 KiB
Plaintext
61 lines
1.8 KiB
Plaintext
;; Function To Be Tested: commonp
|
|
;; NOTE: COMMONP NOT IMPLEMENTED 15 12; SEE AR 7072
|
|
;;
|
|
;; Source: CLtL p. 76
|
|
;;
|
|
;; Chapter 6: Predicates Section 2-2: Specific Data Type Predicates
|
|
;;
|
|
;; Created By: Peter Reidy
|
|
;;
|
|
;; Creation Date: 28 September 86
|
|
;;
|
|
;; Last Update: 28 September 86
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>6-2-2-commonp.test
|
|
;;
|
|
;; Syntax: commonp object
|
|
;;
|
|
;; Function Description: Returns non-nil iff object is a standard CML data type, and NIL otherwise.
|
|
;;
|
|
;; Argument(s): object any cml object
|
|
;;
|
|
;; Returns: non-nil or NIL
|
|
;;
|
|
(do-test-group commonp-group
|
|
:before
|
|
(progn
|
|
(test-defun commonptest (object &optional (expected-value nil))
|
|
"See if (commonp object) <=> (typep object 'common) for any object, and see if the predicate is true or is false of object, depending on expected-value."
|
|
(let ((val (commonp object)))
|
|
(and
|
|
(cond
|
|
(expected-value val)
|
|
(t (null val))
|
|
) ; cond
|
|
(eq val (typep object 'common))
|
|
) ; and
|
|
) ; let
|
|
) ; test-defun
|
|
) ; progn
|
|
(do-test commonp-test
|
|
(every #'(lambda (type) (commonptest type t))
|
|
'(array atom bignum bit bit-vector character common compiled-function complex cons double-float fixnum float function hash-table integer keyword list long-float null number package pathname random-state ratio rational readtable sequence short-float simple-array simple-bit-vector simple-string simple-vector single-float standard-char stream string string-char symbol t vector)
|
|
) ; every
|
|
) ; do-test-commonp-test
|
|
;;
|
|
(do-test not-commonp-test
|
|
(deftype zeroorone () '(member 0 1))
|
|
(notany 'commonptest
|
|
(list
|
|
;; The name of a type isn't a type.
|
|
"array"
|
|
;; A list with a type isn't a type.
|
|
(list 'bignum)
|
|
'(bit)
|
|
) ; list
|
|
) ; notany
|
|
) ; do-test-not-commonp-test
|
|
) ; do-test-group
|
|
STOP
|
|
|