1
0
mirror of synced 2026-05-03 14:49:45 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/15-2-POP.TEST

75 lines
1.6 KiB
Plaintext

;; Function To Be Tested: POP
;;
;; Source: Guy L Steele's CLTL
;; Section: 15.2 Lists
;; Page: 271
;;
;; Created By: Kelly Roach
;;
;; Creation Date: June 27,1986
;;
;; Last Update: June 27,1986
;; July 2, 1986 Sye/ create test cases
;;
;; Filed As: {ERIS}<LISPCORE>CML>TEST>15-2-POP.TEST
;;
;;
;; Syntax: (POP PLACE)
;;
;; Function Description:
;; The form PLACE should be the name of a generalized variable containing a list.
;; The result of POP is the car of the contents of PLACE, and as a side effect the cdr
;; of the contents is stored back into PLACE.
;;
;; Argument(s): PLACE - a list
;;
;; Returns: anything
;;
(do-test "test pop - test cases copied from page 271 of CLtL"
(progn (SETQ STACK '(A B C))
(and (EQ (POP STACK) 'A) (EQUAL STACK '(B C)) )))
(do-test "test pop0"
(and (setq a '(1 2 3 4))
(= (pop a) 1)
(= (pop a) 2)
(= (pop a) 3)
(= (pop a) 4)
(eq (pop a) nil)
(eq (pop a ) ()) ))
(do-test "test pop1"
(let ((a `(a #(1 2 3 4) 100.0 (d e "f" #\i) ,(function +) k) ))
(and (eq (pop a) 'a)
;
(= (pop (cdr a)) 100.0)
;
(vectorp (pop a))
;
(= (funcall (pop (cdr a)) 1 2 3) 6)
;
(equal a '( (d e "f" #\i) k) )
;
(string-equal (pop (cddar a)) "F")
;
(eq (pop (cdr a)) 'k)
;
(equal a '((d e #\i)))
;
(char= (pop (cddar a)) #\i)
;
(equal (pop a) '(d e))
(eq a ())
)))
(do-test "test pop2"
(progn (setq a '(10 20 30 40 50 (60 77 88) (a b c d) (e (f (g (h)))) i j k (99 100)))
(setq aa a b nil)
(dotimes (i (list-length a)) (setq b (cons (pop a) b)))
(equal aa (reverse b))))
;;
;;
STOP