106 lines
3.4 KiB
Plaintext
106 lines
3.4 KiB
Plaintext
;; Function To Be Tested: USE (multiple) (EXEC Command)
|
|
;;
|
|
;; Source: Xerox Common Lisp Implementation Notes (Lyric Beta Release)
|
|
;; Section 20.2 (The Evaluator), Page 28
|
|
;;
|
|
;; Section: The Evaluator
|
|
;;
|
|
;; Created By: John Park
|
|
;;
|
|
;; Creation Date: Feb 4, 1987
|
|
;;
|
|
;; Last Update: Feb 27 , 1987
|
|
;;
|
|
;; Filed As: {ERINYES}<test>lisp>test>exec>multiple-use.u
|
|
;;
|
|
;;
|
|
;; Syntax: USE NEW1 FOR OLD1 AND ....AND NEWn FOR OLDn [IN EventSpec]
|
|
;;
|
|
;; Function Description: This command allows multiple substitues. Substitutes NEW1
|
|
;; for OLD1, NEW2 for OLD2, etc in the events specified by EventSpec, and redoes the
|
|
;; result. NEW and OLD can include lists or symbols.
|
|
;;
|
|
;; Argument(s): NEW (new value) OLD (old value)
|
|
;; EvenSpec (number or sequence)
|
|
;;
|
|
;; Returns: Results of substituted variables in the previous event(s)
|
|
;;
|
|
;; Constraints/Limitations: Due to the nature of Programmer's Assistant commands,
|
|
;; testing them willbe accomplished by using the interlisp function bksysbuf
|
|
;; in do-test form. Comments are incorporated within each command file.
|
|
;; The do-test test setup is titled "MULTIPLE-USE-TEST-SETUP", which executes
|
|
;; the command string. The do-test form within the command file will return T or
|
|
;; "test "quote" failed in file "unknown". " This test file requires TEDIT package.
|
|
;; The test result will be logged automatically in the following file:
|
|
;; {ERIS}<lispcore>test>exec>test.report
|
|
|
|
|
|
(DO-TEST "MULTIPLE-USE-TEST-SETUP"
|
|
(PROGN
|
|
(SETQ TEST-RESULT "{ERIS}<LISPCORE>TEST>EXEC>TEST.REPORT")
|
|
(DEFUN R-FORMAT (STATUS)
|
|
(FORMAT *OUTPUT* "~%COMMAND: MULTIPLE-USE ~%STATUS: ~A DATE: ~A TESTER: ~A~%" STATUS (IL:DATE) IL:USERNAME))
|
|
(SETQ MULTIPLE-USE-COMMAND-STRING
|
|
|
|
"(setq x 10 y 20 x1 11 y1 21)
|
|
(setq first-val (+ x1 y1))
|
|
(setq second-val (+ x y))
|
|
(setq a1 -10 b1 -20)
|
|
;; The following will use a for x and b for y in the last event
|
|
USE A1 FOR X AND B1 FOR Y
|
|
(SETQ SECOND-VAL-1 IL:IT)
|
|
(= second-val-1 (+ a1 b1))
|
|
USE X1 Y1 FOR X Y
|
|
(SETQ SECOND-VAL-2 IL:IT)
|
|
(= second-val (+ x1 y1))
|
|
;; The following will perform distributive substitutions
|
|
(setq w 0)
|
|
(setq w1 1 w2 2 w3 3 w4 4)
|
|
(setq z1 (1+ w))
|
|
;; The following should return 2,3,4, and 5 respectively and reset z to 5
|
|
USE w1 w2 w3 w4 FOR W
|
|
(= z1 5)
|
|
;; The following will perform the equivalent of
|
|
;; USE A FOR D AND X FOR W
|
|
;; USE B FOR D AND Y FOR W
|
|
;; USE C FOR D AND Z FOR W
|
|
(setq D '() W '(W))
|
|
(setq new-list (append d w))
|
|
(setq a '(a) b '(b) c '(c) x '(x) y '(y) z '(z))
|
|
(setq new-list (append d w))
|
|
USE A B C FOR D AND X Y Z FOR W
|
|
;; Now (a x) (b y) and (c z) should be returned respectively and new-list is
|
|
;; bound to the last value returned
|
|
(equal new-list '(c z))
|
|
(setq old-val 10 new-val -9)
|
|
(setq sum (+ old-val new-val))
|
|
;;The following should have the same effect as USE OLD-VAL FOR NEW-VAL
|
|
;; AND NEW-VAL FOR OLD-VAL
|
|
USE OLD-VAL NEW-VAL FOR NEW-VAL OLD-VAL
|
|
(SETQ FIRST-SUM IL:IT)
|
|
USE NEW-VAL OLD-VAL FOR OLD-VAL NEW-VAL IN -3
|
|
(SETQ SECOND-SUM IL:IT)
|
|
|
|
(DO-TEST 'MULTIPLE-USE-TEST-RESULT
|
|
(PROG2 (SETQ *OUTPUT* (OPEN TEST-RESULT :DIRECTION :OUTPUT
|
|
:IF-EXISTS :APPEND))
|
|
(IF (AND (= SECOND-VAL-1 (+ A1 B1))
|
|
(= SECOND-VAL-2 (+ X1 Y1))
|
|
(= Z1 5)
|
|
(EQUAL NEW-LIST '(c z))
|
|
(= FIRST-SUM -18)
|
|
(= SECOND-SUM 20)
|
|
)
|
|
(PROGN (R-FORMAT 'SUCCESS) T)
|
|
(PROGN (R-FORMAT 'FAIL) NIL))
|
|
(CLOSE *OUTPUT*)
|
|
)
|
|
)
|
|
")
|
|
|
|
(IL:BKSYSBUF MULTIPLE-USE-COMMAND-STRING)
|
|
)
|
|
)
|
|
|
|
|