126 lines
3.6 KiB
Plaintext
126 lines
3.6 KiB
Plaintext
;; Function To Be Tested: SMALLP
|
|
;;
|
|
;; Source: IRM, p 9.1
|
|
;;
|
|
;; Chapter 9: Conditionals And Iterative Statements
|
|
;; Section 1: Data Type Predicates
|
|
;;
|
|
;; Created By: Henry Cate III
|
|
;;
|
|
;; Creation Date: March 11, 1987
|
|
;;
|
|
;; Last Update:
|
|
;;
|
|
;; Filed As: {eris}<lispcore>test>DataTypes>SmallP.test
|
|
;;
|
|
;;
|
|
|
|
|
|
(do-test "test simple cases"
|
|
(and
|
|
(eq 5 (il:smallp 5))
|
|
(eq -4 (il:smallp -4))
|
|
(eq nil (il:smallp 'a-smallp))
|
|
(eq nil (il:smallp "a string"))
|
|
))
|
|
|
|
|
|
(do-test "Test go on own function"
|
|
(flet ((temp-small nil 2)
|
|
(temp-large nil -3) )
|
|
(test-defun temp-fun nil 32)
|
|
(and
|
|
(eq 2 (il:smallp (temp-small)))
|
|
(equal -3 (il:smallp (temp-large)))
|
|
(equal 32 (il:smallp (temp-fun)))
|
|
)))
|
|
|
|
|
|
(do-test "Test large and floating aren't small numbers"
|
|
(and
|
|
(eq nil (il:smallp 100000))
|
|
(eq nil (il:smallp 32.4))
|
|
(eq nil (il:smallp 32e6))
|
|
))
|
|
|
|
|
|
(do-test "Test work against system functions"
|
|
(and
|
|
(eq 3 (il:smallp (third '(1 2 3 4 5))))
|
|
(equal 3 (il:smallp (car '(3 2.2 1.1))))
|
|
(equal 2 (il:smallp (second '(1 2 4.5 6))))
|
|
))
|
|
|
|
|
|
(do-test "Try various types of Litatoms"
|
|
(and
|
|
(eq nil (il:smallp 'ABCDEFGHIJKLMNOPQRSTUVWXYZ))
|
|
(eq nil (il:smallp 'A-couple-dashs))
|
|
(eq nil (il:smallp 'Numbers-1234567890))
|
|
|
|
(eq nil (il:smallp 'il:other-packags))
|
|
(eq nil (il:smallp 'il:other-packagsNumbers-1234567890))
|
|
(eq nil (il:smallp 'il:other-packagsA-couple-dashs))
|
|
|
|
(eq nil (il:smallp T))
|
|
(eq nil (il:smallp nil))
|
|
(eq nil (il:smallp ()))
|
|
(eq nil (il:smallp '()))
|
|
(eq nil (il:smallp (list)))
|
|
(eq nil (il:smallp (eq 1 2)))
|
|
))
|
|
|
|
|
|
(do-test "Test stop on own function"
|
|
(flet ((tee nil t) (nill nil nil) (temp-litatom nil 'litatom)
|
|
(temp-string nil "string"))
|
|
(test-defun temp-fun nil 'litatom)
|
|
(test-setq temp-litatom 'il:temp-pointed)
|
|
(and
|
|
(eq nil (il:smallp (tee)))
|
|
(eq nil (il:smallp (nill)))
|
|
(eq nil (il:smallp (temp-litatom)))
|
|
(eq nil (il:smallp (temp-string)))
|
|
(eq nil (il:smallp (temp-fun)))
|
|
(eq nil (il:smallp temp-litatom))
|
|
)))
|
|
|
|
|
|
(do-test "Stop stop on system functions"
|
|
(and
|
|
(eq nil (il:smallp (car '(#*1001 '#( 5 4 3 2 1)))))
|
|
(eq nil (il:smallp (second '(#\. #\k))))
|
|
))
|
|
|
|
|
|
(do-test "Test arrays aren't small numbers"
|
|
(and
|
|
(eq nil (il:smallp (make-array '(2 2))))
|
|
(eq nil (il:smallp (make-array '(6 6 6) :element-type '(or integer string))))
|
|
(eq nil (il:smallp (make-array 5 :element-type 'bit :initial-contents '(0 0 1 1 0))))
|
|
(eq nil (il:smallp (make-array '(5 5) :displaced-to (make-array '(6 6 6) :element-type '(or integer string)))))
|
|
(eq nil (il:smallp (make-array 50 :initial-element 0)))
|
|
(eq nil (il:smallp (make-array 20 :element-type 'string-char :initial-element #\0)))
|
|
))
|
|
|
|
|
|
(do-test "Test other datatypes aren't small numbers"
|
|
(and
|
|
(eq nil (il:smallp #\backspace)) ; character
|
|
(eq nil (il:smallp #\*)) ; character
|
|
(eq nil (il:smallp #\.)) ; character
|
|
(eq nil (il:smallp (make-hash-table))) ; hash table
|
|
(eq nil (il:smallp (car (list-all-packages)))) ; packages
|
|
(eq nil (il:smallp (pathname nil))) ; pathname
|
|
(eq nil (il:smallp *random-state*)) ; ramdom state
|
|
(eq nil (il:smallp #'cons)) ; compiled function
|
|
(eq nil (il:smallp (copy-readtable))) ; readtable
|
|
(eq nil (il:smallp #*1001)) ; simple-bit-vector
|
|
(eq nil (il:smallp "twine")) ; simple-string
|
|
(eq nil (il:smallp (make-synonym-stream nil))) ; stream
|
|
(eq nil (il:smallp '#( 5 4 3 2 1))) ; vector
|
|
))
|
|
|
|
STOP
|
|
|