75 lines
2.4 KiB
Plaintext
75 lines
2.4 KiB
Plaintext
;; Function To Be Tested:
|
|
;;
|
|
;; Source: CLtL Section 9.3: Type declaration for forms Page: 161
|
|
;;
|
|
;; Created By: Karin M. Sye
|
|
;;
|
|
;; Creation Date: Oct. 8,1986
|
|
;;
|
|
;; Last Update: Oct. 8,1986
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>9-3-the.test
|
|
;;
|
|
;;
|
|
;; Syntax: the VALUE-TYPE FORM
|
|
;;
|
|
;; Function Description: The function is used to declare the type of the value of an unnamed form. It returns the
|
|
;; evaluated value of FORM. It is an error if what is produced by the form does not conform to
|
|
;; the data type specified by VALUE-TYPE.
|
|
;;
|
|
;; Argument(s): VALUE-TYPE - a lisp type specifier
|
|
;; FORM -
|
|
;;
|
|
;; Returns: any lisp object
|
|
;;
|
|
|
|
(do-test "test the 0"
|
|
(and (= (the integer 30) 30)
|
|
(= (the float 23.9) 23.9)
|
|
(= (the (integer 2 10) 2) 2)
|
|
(= (the (mod 100) (1- 1)) 0)
|
|
(= (the (mod 1000) (1+ 998)) 999)
|
|
(= (the (unsigned-byte 3) 7) 7)
|
|
(= (the (unsigned-byte 4) 13) 13)
|
|
(= (the (float -99.2 99.2) -99.01) -99.01)
|
|
(= (the complex #c(1 -2)) #c(1 -2))
|
|
(= (the (complex float) #c(1.1 -9.3)) #c(1.1 -9.3))
|
|
(= (the (complex integer) #c(2 10)) #c(2 10))
|
|
(= (the (complex ratio) #c(2/3 5/9)) #c(2/3 5/9))
|
|
(= (the rational 20) 20)
|
|
(= (the (rational 2/13 2/5) 2/7) 2/7)
|
|
)
|
|
)
|
|
|
|
(do-test "test the 1"
|
|
(and (equal (the string "jkfldjskl") "jkfldjskl")
|
|
(equal (the (string 20) (make-string 20 :initial-element #\a)) "aaaaaaaaaaaaaaaaaaaa")
|
|
(equalp (the simple-vector (vector 1 0 1 0 0 0 1 1)) #*10100011)
|
|
(equalp (the (bit-vector 10) #*0000011111) (vector 0 0 0 0 0 1 1 1 1 1))
|
|
(equalp (the array (make-array '(2 2) :initial-contents '((a b) (c d)) ))
|
|
(make-array '(2 2) :initial-contents '((a b) (c d)) ))
|
|
(equalp (the (vector * 5) (vector 1 2 3 4 5)) (vector 1 2 3 4 5))
|
|
)
|
|
)
|
|
|
|
(do-test "test the 2"
|
|
(and (= (the (satisfies evenp) 10) 10)
|
|
(char= (the (satisfies characterp) #\q) #\q)
|
|
(= (the (member 2 4 6 8 10) 6) 6)
|
|
(eq (the (member abc def ghi) 'def) 'def)
|
|
(equal (the (not list) "abc") "abc")
|
|
(eq (the (and symbol list) nil) nil)
|
|
(eq (the (or t nil) (find #\a "bcd")) nil)
|
|
)
|
|
)
|
|
|
|
(do-test "test the 3"
|
|
(and (equal (multiple-value-list (the (values integer integer float) (values 2 3 1.2))) '(2 3 1.2))
|
|
(equal (multiple-value-list (the (values list string character) (values '(1 2) "12" #\1))) '((1 2) "12" #\1))
|
|
(equal (multiple-value-list (the (values bit ratio complex) (values 1 2/9 #C(1 1)))) '(1 2/9 #c(1 1)))
|
|
)
|
|
)
|
|
|
|
STOP
|
|
|
|
|