50 lines
1.6 KiB
Plaintext
50 lines
1.6 KiB
Plaintext
;; Function To Be Tested: progn
|
|
;;
|
|
;; Source: Steele's book Section 7.4: simple sequencing Page: 109
|
|
;;
|
|
;; Created By: Karin M. Sye
|
|
;;
|
|
;; Creation Date: May 29, 1986
|
|
;;
|
|
;; Last Update: May 29, 1986
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>7-4-progn.test
|
|
;;
|
|
;;
|
|
;; Syntax: PROGN {form}*
|
|
;;
|
|
;; Function Description: PROGN takes a number of forms and evaluates them sequentially. It discards the results
|
|
;; of all forms but the last one and returns the value(s) of the last form.
|
|
;;
|
|
;; Argument(s): {form}* - a sequence of forms
|
|
;;
|
|
;; Returns: nil - if there are no forms
|
|
;; value(s) of the last form - otherwise
|
|
;;
|
|
;;
|
|
(do-test test-progn0
|
|
;;
|
|
;; if there are no forms in progn, be sure it returns nil
|
|
;;
|
|
(eq nil (progn)))
|
|
|
|
(do-test test-progn1
|
|
(and (eq (progn 1 2 3 4 ) 4)
|
|
(eq (progn 'a 'b 'c 'd 'e 'f 'g 'x 'z 'y) 'y)
|
|
(equal (progn "simple-string") "simple-string")
|
|
(equal (progn (setq x (+ 3 3 4)) (setq y (- 10 2 3)) (setq z (1+ (* 5 2 1))) (max x y z)) 11)
|
|
(equal (progn (setq m 10) (multiple-value-setq (a b c) (values (incf m 100) (decf m 50) (gcd 7 21 28))) (list a b c))
|
|
'(110 60 7))))
|
|
|
|
(do-test test-progn2
|
|
;;
|
|
;; check if progn returns multiple values
|
|
;;
|
|
(and (equal (multiple-value-list (progn (values 10 20 30))) '(10 20 30))
|
|
(equal (multiple-value-list (progn (setq a :bar) (setq b :foo) (values-list (list a b))))
|
|
'(:bar :foo))))
|
|
;;
|
|
;;
|
|
STOP
|
|
|
|
|