1
0
mirror of synced 2026-05-01 05:59:33 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/24-3-ECASE.TEST

71 lines
1.9 KiB
Plaintext

;; Function To Be Tested: ecase
;;
;; Source: Guy L Steele's CLTL
;; Section: 24.3 ERRORS (Special Forms for Exhaustive Case Analysis)
;; Page: 436
;;
;; Created By: John Park
;;
;; Creation Date: Nov 7, 1986
;;
;; Last Update: Jan 15, 1987
;;
;; Filed As: {ERIS}<LISPCORE>CML>TEST>24-3-ecase.test
;;
;;
;; Syntax: (ecase keyform {({({key}*)|key} {form}*)}*
;;
;; Function Description: This control construct is similar to case, but no explicit
;; otherwise or T clause is permitted. If no clause is satisfied, ecase signals
;; an error with a message constructed from the clauses. It is not permissible to
;; continue from this error. The name of this function stands for "exhaustive
;; case" or "error-checking case."
;;
;; Argument(s): Keyplace: Key (variable)
;; (type {form}): type case for error checking
;;
;; Returns:
;;
;; Constraints/Limitations: Due to the nature of ecase function, which enters
;; the debugger (break), this test should be conducted manually to see if correct
;; error messages are returned. Tests requiring user interface are commented out.
(do-test "ecase-test0"
(macro-function 'ecase) ; Does ecase have a macro definition?
)
(do-test "ecase-test1"
(and (setq x 'alpha)
(defun foo () 'foo-for-alpha)
(defun bar () 'bar-for-omega)
(defun baz () 'baz-for-zeta)
(setq alpha 1 omega 2 zeta 3 phi 4)
(equal (mapcar #'(lambda (x)
(ecase x
(alpha (foo))
(omega (bar))
((zeta phi) (baz))))
'(alpha omega zeta phi))
(list (foo) (bar) (baz) (baz)))
)
) ; This should not break since each of the three clauses is satisfied.
;; The following (ecase-test2) should break with the appropriate error message
;; "Error: The value of X, 1/3, is neither an integer nor a symbol"
;;
;; (progn (setq x 1/3)
;; (ecase x
;; (alpha (foo))
;; (omega (bar))
;; ((zeta phi) (baz)))
;; )
STOP