1
0
mirror of synced 2026-02-02 23:21:17 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/STRINGP.TEST

128 lines
3.9 KiB
Plaintext

;; Function To Be Tested: StringP
;;
;; Source: IRM, p 9.2
;;
;; Chapter 9: Conditionals And Iterative Statements
;; Section 1: Data Type Predicates
;;
;; Created By: Henry Cate III
;;
;; Creation Date: March 17, 1987
;;
;; Last Update:
;;
;; Filed As: {eris}<lispcore>test>DataTypes>StringP.test
;;
;;
(do-test "test simple cases"
(and
(equal "a string" (il:stringp "a string"))
(equal "Try 12321*& ()" (il:stringp "Try 12321*& ()"))
(eq nil (il:stringp -5))
(eq nil (il:stringp 1000000))
(eq nil (il:stringp 'a-floatp))
))
(do-test "Test lists of various things"
(and
(equal "ABCDEFGHIJKLM" (il:stringp "ABCDEFGHIJKLM"))
(equal "NOPQRSTUVWXYZ" (il:stringp "NOPQRSTUVWXYZ"))
(equal "abcdefghijklm" (il:stringp "abcdefghijklm"))
(equal "nopqrstuvwxyz" (il:stringp "nopqrstuvwxyz"))
(equal "1234567890" (il:stringp "1234567890"))
(equal "!@#$%^&*()" (il:stringp "!@#$%^&*()"))
(equal "-=[];'`,./" (il:stringp "-=[];'`,./"))
(equal "_+{}:\"~<>?" (il:stringp "_+{}:\"~<>?"))
))
(do-test "Test go on own function"
(flet ((temp-small nil "abcdefghijklm") )
(test-defun temp-fun nil "-=[];'`,./")
(and
(equal "abcdefghijklm" (il:stringp (temp-small)))
(equal "-=[];'`,./" (il:stringp (temp-fun)))
)))
(do-test "Test work against system functions"
(and
(equal "A rat in the"
(il:stringp (concatenate 'string "A rat" " in the")))
(equal "LITATOM" (il:stringp (il:mkstring 'litatom)))
))
(do-test "Try various types of Litatoms"
(and
(eq nil (il:stringp 'ABCDEFGHIJKLMNOPQRSTUVWXYZ))
(eq nil (il:stringp 'A-couple-dashs))
(eq nil (il:stringp 'Numbers-1234567890))
(eq nil (il:stringp 'il:other-packags))
(eq nil (il:stringp 'il:other-packagsNumbers-1234567890))
(eq nil (il:stringp 'il:other-packagsA-couple-dashs))
(eq nil (il:stringp T))
(eq nil (il:stringp nil))
(eq nil (il:stringp ()))
(eq nil (il:stringp '()))
(eq nil (il:stringp (list)))
(eq nil (il:stringp (eq 1 2)))
))
(do-test "Test stop on own function"
(flet ((tee nil t) (nill nil nil) (temp-litatom nil 'litatom)
(temp-number nil 1234))
(test-defun temp-fun nil 45.65)
(test-setq temp-litatom 'il:temp-pointed)
(and
(eq nil (il:stringp (tee)))
(eq nil (il:stringp (nill)))
(eq nil (il:stringp (temp-litatom)))
(eq nil (il:stringp (temp-number)))
(eq nil (il:stringp (temp-fun)))
(eq nil (il:stringp temp-litatom))
)))
(do-test "Stop on non-strings from system functions"
(and
(eq nil (il:stringp (car '(#*1001 '#( 5 4 3 2 1)))))
(eq nil (il:stringp (second '(#\. #\k))))
))
(do-test "Test arrays aren't strings"
(and
(eq nil (il:stringp (make-array '(2 2))))
(eq nil (il:stringp (make-array '(6 6 6) :element-type '(or integer string))))
(eq nil (il:stringp (make-array 5 :element-type 'bit :initial-contents '(0 0 1 1 0))))
(eq nil (il:stringp (make-array '(5 5) :displaced-to (make-array '(6 6 6) :element-type '(or integer string)))))
(eq nil (il:stringp (make-array 50 :initial-element 0)))
))
(do-test "Test other datatypes aren't strings"
(and
(eq nil (il:stringp #\backspace)) ; character
(eq nil (il:stringp #\*)) ; character
(eq nil (il:stringp #\.)) ; character
(eq nil (il:stringp (make-hash-table))) ; hash table
(eq nil (il:stringp (car (list-all-packages)))) ; packages
(eq nil (il:stringp (pathname nil))) ; pathname
(eq nil (il:stringp *random-state*)) ; ramdom state
(eq nil (il:stringp #'cons)) ; compiled function
(eq nil (il:stringp (copy-readtable))) ; readtable
(eq nil (il:stringp #*1001)) ; simple-bit-vector
(eq nil (il:stringp (make-synonym-stream nil))) ; stream
(eq nil (il:stringp '#( 5 4 3 2 1))) ; vector
))
STOP