15dfecf96Smrg;;
25dfecf96Smrg;; Copyright (c) 2002 by The XFree86 Project, Inc.
35dfecf96Smrg;;
45dfecf96Smrg;; Permission is hereby granted, free of charge, to any person obtaining a
55dfecf96Smrg;; copy of this software and associated documentation files (the "Software"),
65dfecf96Smrg;; to deal in the Software without restriction, including without limitation
75dfecf96Smrg;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
85dfecf96Smrg;; and/or sell copies of the Software, and to permit persons to whom the
95dfecf96Smrg;; Software is furnished to do so, subject to the following conditions:
105dfecf96Smrg;;
115dfecf96Smrg;; The above copyright notice and this permission notice shall be included in
125dfecf96Smrg;; all copies or substantial portions of the Software.
135dfecf96Smrg;;
145dfecf96Smrg;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155dfecf96Smrg;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165dfecf96Smrg;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
175dfecf96Smrg;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
185dfecf96Smrg;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
195dfecf96Smrg;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
205dfecf96Smrg;; SOFTWARE.
215dfecf96Smrg;;
225dfecf96Smrg;; Except as contained in this notice, the name of the XFree86 Project shall
235dfecf96Smrg;; not be used in advertising or otherwise to promote the sale, use or other
245dfecf96Smrg;; dealings in this Software without prior written authorization from the
255dfecf96Smrg;; XFree86 Project.
265dfecf96Smrg;;
275dfecf96Smrg;; Author: Paulo César Pereira de Andrade
285dfecf96Smrg;;
295dfecf96Smrg;;
305dfecf96Smrg;; $XFree86: xc/programs/xedit/lisp/test/stream.lsp,v 1.3 2002/12/06 03:25:29 paulo Exp $
315dfecf96Smrg;;
325dfecf96Smrg
335dfecf96Smrg;; most format tests from the cltl second edition samples
345dfecf96Smrg
355dfecf96Smrg;; basic io/format/pathname/stream tests
365dfecf96Smrg
375dfecf96Smrg(defun do-format-test (error-test expect arguments
385dfecf96Smrg		    &aux result (error t) unused error-value)
395dfecf96Smrg    (multiple-value-setq
405dfecf96Smrg	(unused error-value)
415dfecf96Smrg	(ignore-errors
425dfecf96Smrg	    (setq result (apply #'format nil arguments))
435dfecf96Smrg	    (setq error nil)
445dfecf96Smrg	)
455dfecf96Smrg    )
465dfecf96Smrg    (if error-test
475dfecf96Smrg	(or error
485dfecf96Smrg	    (format t "ERROR: no error for (format nil~{ ~S~}), result was ~S~%"
495dfecf96Smrg		arguments result))
505dfecf96Smrg	(if error
515dfecf96Smrg	    (format t "ERROR: (format nil~{ ~S~}) => ~S~%" arguments error-value)
525dfecf96Smrg	    (or (string= result expect)
535dfecf96Smrg		(format t "(format nil~{ ~S~}) => should be ~S not ~S~%"
545dfecf96Smrg		    arguments expect result)))
555dfecf96Smrg    )
565dfecf96Smrg)
575dfecf96Smrg
585dfecf96Smrg(defun format-test (expect &rest arguments)
595dfecf96Smrg    (do-format-test nil expect arguments))
605dfecf96Smrg
615dfecf96Smrg(defun format-error (&rest arguments)
625dfecf96Smrg    (do-format-test t nil arguments))
635dfecf96Smrg
645dfecf96Smrg
655dfecf96Smrg
665dfecf96Smrg(defun compare-test (test expect function arguments
675dfecf96Smrg		     &aux result (error t) unused error-value)
685dfecf96Smrg    (multiple-value-setq
695dfecf96Smrg	(unused error-value)
705dfecf96Smrg	(ignore-errors
715dfecf96Smrg	    (setq result (apply function arguments))
725dfecf96Smrg	    (setq error nil)
735dfecf96Smrg	)
745dfecf96Smrg    )
755dfecf96Smrg    (if error
765dfecf96Smrg	(format t "ERROR: (~S~{ ~S~}) => ~S~%" function arguments error-value)
775dfecf96Smrg	(or (funcall test result expect)
785dfecf96Smrg	    (format t "(~S~{ ~S~}) => should be ~S not ~S~%"
795dfecf96Smrg		function arguments expect result
805dfecf96Smrg	    )
815dfecf96Smrg	)
825dfecf96Smrg    )
835dfecf96Smrg)
845dfecf96Smrg
855dfecf96Smrg(defun compare-eval (test expect form
865dfecf96Smrg		     &aux result (error t) unused error-value)
875dfecf96Smrg    (multiple-value-setq
885dfecf96Smrg	(unused error-value)
895dfecf96Smrg	(ignore-errors
905dfecf96Smrg	    (setq result (eval form))
915dfecf96Smrg	    (setq error nil)
925dfecf96Smrg	)
935dfecf96Smrg    )
945dfecf96Smrg    (if error
955dfecf96Smrg	(format t "ERROR: ~S => ~S~%" form error-value)
965dfecf96Smrg	(or (funcall test result expect)
975dfecf96Smrg	    (format t "~S => should be ~S not ~S~%"
985dfecf96Smrg		form expect result
995dfecf96Smrg	    )
1005dfecf96Smrg	)
1015dfecf96Smrg    )
1025dfecf96Smrg)
1035dfecf96Smrg
1045dfecf96Smrg(defun error-test (function &rest arguments &aux result (error t))
1055dfecf96Smrg    (ignore-errors
1065dfecf96Smrg	(setq result (apply function arguments))
1075dfecf96Smrg	(setq error nil)
1085dfecf96Smrg    )
1095dfecf96Smrg    (or error
1105dfecf96Smrg	(format t "ERROR: no error for (~S~{ ~S~}), result was ~S~%"
1115dfecf96Smrg	    function arguments result)
1125dfecf96Smrg    )
1135dfecf96Smrg)
1145dfecf96Smrg
1155dfecf96Smrg(defun error-eval (form &aux result (error t))
1165dfecf96Smrg    (ignore-errors
1175dfecf96Smrg	(setq result (eval form))
1185dfecf96Smrg	(setq error nil)
1195dfecf96Smrg    )
1205dfecf96Smrg    (or error
1215dfecf96Smrg	(format t "ERROR: no error for ~S, result was ~S~%" form result)
1225dfecf96Smrg    )
1235dfecf96Smrg)
1245dfecf96Smrg
1255dfecf96Smrg(defun eq-test (expect function &rest arguments)
1265dfecf96Smrg    (compare-test #'eq expect function arguments))
1275dfecf96Smrg
1285dfecf96Smrg(defun eql-test (expect function &rest arguments)
1295dfecf96Smrg    (compare-test #'eql expect function arguments))
1305dfecf96Smrg
1315dfecf96Smrg(defun equal-test (expect function &rest arguments)
1325dfecf96Smrg    (compare-test #'equal expect function arguments))
1335dfecf96Smrg
1345dfecf96Smrg(defun equalp-test (expect function &rest arguments)
1355dfecf96Smrg    (compare-test #'equalp expect function arguments))
1365dfecf96Smrg
1375dfecf96Smrg(defun eq-eval (expect form)
1385dfecf96Smrg    (compare-eval #'eq expect form))
1395dfecf96Smrg
1405dfecf96Smrg(defun eql-eval (expect form)
1415dfecf96Smrg    (compare-eval #'eql expect form))
1425dfecf96Smrg
1435dfecf96Smrg(defun equal-eval (expect form)
1445dfecf96Smrg    (compare-eval #'equal expect form))
1455dfecf96Smrg
1465dfecf96Smrg(defun equalp-eval (expect form)
1475dfecf96Smrg    (compare-eval #'equalp expect form))
1485dfecf96Smrg
1495dfecf96Smrg(defun bool-test (expect function &rest arguments
1505dfecf96Smrg		  &aux result (error t) unused error-value)
1515dfecf96Smrg    (multiple-value-setq
1525dfecf96Smrg	(unused error-value)
1535dfecf96Smrg	(ignore-errors
1545dfecf96Smrg	    (setq result (apply function arguments))
1555dfecf96Smrg	    (setq error nil)
1565dfecf96Smrg	)
1575dfecf96Smrg    )
1585dfecf96Smrg    (if error
1595dfecf96Smrg	(format t "ERROR: (~S~{ ~S~}) => ~S~%" function arguments error-value)
1605dfecf96Smrg	(or (eq (null result) (null expect))
1615dfecf96Smrg	    (format t "(~S~{ ~S~}) => should be ~A not ~A~%"
1625dfecf96Smrg		function arguments expect result
1635dfecf96Smrg	    )
1645dfecf96Smrg	)
1655dfecf96Smrg    )
1665dfecf96Smrg)
1675dfecf96Smrg
1685dfecf96Smrg(defun bool-eval (expect form &aux result (error t) unused error-value)
1695dfecf96Smrg    (multiple-value-setq
1705dfecf96Smrg	(unused error-value)
1715dfecf96Smrg	(ignore-errors
1725dfecf96Smrg	    (setq result (eval form))
1735dfecf96Smrg	    (setq error nil)
1745dfecf96Smrg	)
1755dfecf96Smrg    )
1765dfecf96Smrg    (if error
1775dfecf96Smrg	(format t "ERROR: ~S => ~S~%" form error-value)
1785dfecf96Smrg	(or (eq (null result) (null expect))
1795dfecf96Smrg	    (format t "~S => should be ~A not ~A~%"
1805dfecf96Smrg		form expect result
1815dfecf96Smrg	    )
1825dfecf96Smrg	)
1835dfecf96Smrg    )
1845dfecf96Smrg)
1855dfecf96Smrg
1865dfecf96Smrg
1875dfecf96Smrg;; format				- function
1885dfecf96Smrg
1895dfecf96Smrg;; ~c
1905dfecf96Smrg(format-test "A" "~C" #\A)
1915dfecf96Smrg(format-test " " "~C" #\Space)
1925dfecf96Smrg(format-test "A" "~:C" #\A)
1935dfecf96Smrg(format-test "Space" "~:C" #\Space)
1945dfecf96Smrg(format-test "#\\A" "~@C" #\A)
1955dfecf96Smrg(format-test "#\\Space" "~@C" #\Space)
1965dfecf96Smrg(format-test " " "~A" #\Space)
1975dfecf96Smrg(let ((*print-escape* t)) (format-test " " "~A" #\Space))
1985dfecf96Smrg(format-test "#\\Space" "~S" #\Space)
1995dfecf96Smrg(let ((*print-escape* nil)) (format-test "#\\Space" "~S" #\Space))
2005dfecf96Smrg
2015dfecf96Smrg;; ~%
2025dfecf96Smrg(format-test "
2035dfecf96Smrg" "~%")
2045dfecf96Smrg(format-test "
2055dfecf96Smrg
2065dfecf96Smrg
2075dfecf96Smrg" "~3%")
2085dfecf96Smrg
2095dfecf96Smrg;; ~&
2105dfecf96Smrg(format-test "" "~&")
2115dfecf96Smrg(format-test "
2125dfecf96Smrg" "~2&")
2135dfecf96Smrg
2145dfecf96Smrg;; ~|
2155dfecf96Smrg(format-test "" "~|")
2165dfecf96Smrg
2175dfecf96Smrg;; ~~
2185dfecf96Smrg(format-test "~~~" "~3~")
2195dfecf96Smrg
2205dfecf96Smrg;; radix
2215dfecf96Smrg(format-test "1101" "~,,' ,4:B" 13)
2225dfecf96Smrg(format-test "1 0001" "~,,' ,4:B" 17)
2235dfecf96Smrg(format-test "1101 0000 0101" "~14,,' ,4:B" 3333)
2245dfecf96Smrg(format-test "1 22" "~3,,,' ,2:R" 17)
2255dfecf96Smrg(format-test "6|55|35" "~,,'|,2:D" #xFFFF)
2265dfecf96Smrg(format-test "1,000,000" "~,,,3:D" 1000000)
2275dfecf96Smrg(format-test "one hundred and twenty-three thousand, four hundred and fifty-six"
2285dfecf96Smrg	"~R" 123456)
2295dfecf96Smrg(format-test "six hundred and fifty-four thousand, three hundred twenty-first"
2305dfecf96Smrg	"~:R" 654321)
2315dfecf96Smrg(format-test "MCCXXXIV" "~@R" 1234)
2325dfecf96Smrg(format-test "MCCXXXXVIIII" "~@:R" 1249)
2335dfecf96Smrg(format-test "3039" "~X" 12345)
2345dfecf96Smrg(format-test "30071" "~O" 12345)
2355dfecf96Smrg(format-test "9IX" "~36R" 12345)
2365dfecf96Smrg(format-test "11000000111001" "~B" 12345)
2375dfecf96Smrg(format-test "The answer is 5." "The answer is ~D." 5)
2385dfecf96Smrg(format-test "The answer is   5." "The answer is ~3D." 5)
2395dfecf96Smrg(format-test "The answer is 005." "The answer is ~3,'0D." 5)
2405dfecf96Smrg(format-test "1111 1010 1100 1110" "~,,' ,4:B" #xFACE)
2415dfecf96Smrg(format-test "1 1100 1110" "~,,' ,4:B" #x1CE)
2425dfecf96Smrg(format-test "1111 1010 1100 1110" "~19,,' ,4:B" #xFACE)
2435dfecf96Smrg(format-test "        1 1100 1110" "~19,,' ,4:B" #x1CE)
2445dfecf96Smrg
2455dfecf96Smrg;; 6.37 and 6.38 are correct
2465dfecf96Smrg#+xedit (format-test "6.38" "~4,2F" 6.375d0)
2475dfecf96Smrg(format-test "10.0" "~,1F" 9.995d0)
2485dfecf96Smrg;; 6.37E+2 and 6.38E+2 are correct
2495dfecf96Smrg#+xedit (format-test " 6.38E+2" "~8,2E" 637.5)
2505dfecf96Smrg(do*
2515dfecf96Smrg    (
2525dfecf96Smrg    (n '(3.14159 -3.14159 100.0 1234.0 0.006) (cdr n))
2535dfecf96Smrg    (r '("  3.14| 31.42|  3.14|3.1416|3.14|3.14159"
2545dfecf96Smrg	 " -3.14|-31.42| -3.14|-3.142|-3.14|-3.14159"
2555dfecf96Smrg	 "100.00|******|100.00| 100.0|100.00|100.0"
2565dfecf96Smrg	 "1234.00|******|??????|1234.0|1234.00|1234.0"
2575dfecf96Smrg	 "  0.01|  0.06|  0.01| 0.006|0.01|0.006") (cdr r))
2585dfecf96Smrg    (x (car n) (car n))
2595dfecf96Smrg    )
2605dfecf96Smrg    ((endp n))
2615dfecf96Smrg    (format-test (car r)
2625dfecf96Smrg	"~6,2F|~6,2,1,'*F|~6,2,,'?F|~6F|~,2F|~F" x x x x x x)
2635dfecf96Smrg)
2645dfecf96Smrg(do*
2655dfecf96Smrg    (
2665dfecf96Smrg    (n '(3.14159 -3.14159 1100.0 1.1e13 #+xedit 1.1e120) (cdr n))
2675dfecf96Smrg    (r '("  3.14E+0| 31.42$-01|+.003E+03|  3.14E+0"
2685dfecf96Smrg	 " -3.14E+0|-31.42$-01|-.003E+03| -3.14E+0"
2695dfecf96Smrg	 "  1.10E+3| 11.00$+02|+.001E+06|  1.10E+3"
2705dfecf96Smrg	 "*********| 11.00$+12|+.001E+16| 1.10E+13"
2715dfecf96Smrg	 #+xedit
2725dfecf96Smrg	 "*********|??????????|%%%%%%%%%|1.10E+120") (cdr r))
2735dfecf96Smrg    (x (car n) (car n))
2745dfecf96Smrg    )
2755dfecf96Smrg    ((endp n))
2765dfecf96Smrg    (format-test (car r)
2775dfecf96Smrg	"~9,2,1,,'*E|~10,3,2,2,'?,,'$E|~9,3,2,-2,'%@E|~9,2E" x x x x)
2785dfecf96Smrg)
2795dfecf96Smrg(do
2805dfecf96Smrg    (
2815dfecf96Smrg    (k -5 (1+ k))
2825dfecf96Smrg    (r '("Scale factor -5: | 0.000003E+06|"
2835dfecf96Smrg	 "Scale factor -4: | 0.000031E+05|"
2845dfecf96Smrg	 "Scale factor -3: | 0.000314E+04|"
2855dfecf96Smrg	 "Scale factor -2: | 0.003142E+03|"
2865dfecf96Smrg	 "Scale factor -1: | 0.031416E+02|"
2875dfecf96Smrg	 "Scale factor  0: | 0.314159E+01|"
2885dfecf96Smrg	 "Scale factor  1: | 3.141590E+00|"
2895dfecf96Smrg	 "Scale factor  2: | 31.41590E-01|"
2905dfecf96Smrg	 "Scale factor  3: | 314.1590E-02|"
2915dfecf96Smrg	 "Scale factor  4: | 3141.590E-03|"
2925dfecf96Smrg	 "Scale factor  5: | 31415.90E-04|"
2935dfecf96Smrg	 "Scale factor  6: | 314159.0E-05|"
2945dfecf96Smrg	 "Scale factor  7: | 3141590.E-06|") (cdr r))
2955dfecf96Smrg    )
2965dfecf96Smrg    ((endp r))
2975dfecf96Smrg    (format-test (car r) "Scale factor ~2D: | ~12,6,2,VE|" k k 3.14159)
2985dfecf96Smrg)
2995dfecf96Smrg(do*
3005dfecf96Smrg    (
3015dfecf96Smrg    (n '(0.0314159 0.314159 3.14159 31.4159 314.159 3141.59 3.14E12
3025dfecf96Smrg	 #+xedit 3.14d120) (cdr n))
3035dfecf96Smrg    (r '("  3.14E-2|314.2$-04|0.314E-01|  3.14E-2"
3045dfecf96Smrg         "  0.31   |0.314    |0.314    | 0.31    "
3055dfecf96Smrg         "   3.1   | 3.14    | 3.14    |  3.1    "
3065dfecf96Smrg         "   31.   | 31.4    | 31.4    |  31.    "
3075dfecf96Smrg         "  3.14E+2| 314.    | 314.    |  3.14E+2"
3085dfecf96Smrg         "  3.14E+3|314.2$+01|0.314E+04|  3.14E+3"
3095dfecf96Smrg         "*********|314.0$+10|0.314E+13| 3.14E+12"
3105dfecf96Smrg         #+xedit "*********|?????????|%%%%%%%%%|3.14E+120") (cdr r))
3115dfecf96Smrg    (x (car n) (car n))
3125dfecf96Smrg    )
3135dfecf96Smrg    ((endp n))
3145dfecf96Smrg    (format-test (car r) "~9,2,1,,'*G|~9,3,2,3,'?,,'$G|~9,3,2,0,'%G|~9,2G"
3155dfecf96Smrg	x x x x)
3165dfecf96Smrg)
3175dfecf96Smrg(format-test "  1." "~4,0f" 0.5)
3185dfecf96Smrg(format-test "  0." "~4,0f" 0.4)
3195dfecf96Smrg
3205dfecf96Smrg;; ~p
3215dfecf96Smrg(setq n 3)
3225dfecf96Smrg(format-test "3 items found.""~D item~:P found." n)
3235dfecf96Smrg(format-test "three dogs are here." "~R dog~:[s are~; is~] here." n (= n 1))
3245dfecf96Smrg(format-test "three dogs are here." "~R dog~:*~[s are~; is~:;s are~] here." n)
3255dfecf96Smrg(format-test "Here are three puppies.""Here ~[are~;is~:;are~] ~:*~R pupp~:@P." n)
3265dfecf96Smrg(format-test "7 tries/1 win" "~D tr~:@P/~D win~:P" 7 1)
3275dfecf96Smrg(format-test "1 try/0 wins" "~D tr~:@P/~D win~:P" 1 0)
3285dfecf96Smrg(format-test "1 try/3 wins" "~D tr~:@P/~D win~:P" 1 3)
3295dfecf96Smrg
3305dfecf96Smrg;; ~t
3315dfecf96Smrg(format-test "        foo" "~8Tfoo")
3325dfecf96Smrg#+xedit (format-test  "         foo" "~8,3Tfoo")
3335dfecf96Smrg(format-test "         foo" "~8,3@Tfoo")
3345dfecf96Smrg(format-test "   foo" "~1,3@Tfoo")
3355dfecf96Smrg
3365dfecf96Smrg;; ~*
3375dfecf96Smrg(format-test "2" "~*~D" 1 2 3 4)
3385dfecf96Smrg(format-test "4" "~3*~D" 1 2 3 4)
3395dfecf96Smrg(format-test "2" "~3*~2:*~D" 1 2 3 4)
3405dfecf96Smrg(format-test "4 3 2 1 2 3 4" "~3@*~D ~2@*~D ~1@*~D ~0@*~D ~D ~D ~D" 1 2 3 4)
3415dfecf96Smrg
3425dfecf96Smrg;; ~?
3435dfecf96Smrg(format-test "<Foo 5> 7" "~? ~D" "<~A ~D>" '("Foo" 5) 7)
3445dfecf96Smrg(format-test "<Foo 5> 7" "~? ~D" "<~A ~D>" '("Foo" 5 14) 7)
3455dfecf96Smrg(format-test "<Foo 5> 7" "~@? ~D" "<~A ~D>" "Foo" 5 7)
3465dfecf96Smrg(format-test "<Foo 5> 14" "~@? ~D" "<~A ~D>" "Foo" 5 14 7)
3475dfecf96Smrg
3485dfecf96Smrg
3495dfecf96Smrg(format-error "~:[abc~:@(def~;ghi~:@(jkl~]mno~)" 1)
3505dfecf96Smrg(format-error "~?ghi~)" "abc~@(def")
3515dfecf96Smrg
3525dfecf96Smrg
3535dfecf96Smrg;; ~(...~)
3545dfecf96Smrg(format-test "XIV xiv" "~@R ~(~@R~)" 14 14)
3555dfecf96Smrg(format-test "Zero errors detected." "~@(~R~) error~:P detected." 0)
3565dfecf96Smrg(format-test "One error detected." "~@(~R~) error~:P detected." 1)
3575dfecf96Smrg(format-test "Twenty-three errors detected." "~@(~R~) error~:P detected." 23)
3585dfecf96Smrg
3595dfecf96Smrg;; ~[...~]
3605dfecf96Smrg(format-test "Persian Cat" "~[Siamese~;Manx~;Persian~] Cat" 2)
3615dfecf96Smrg(format-test " Cat" "~[Siamese~;Manx~;Persian~] Cat" 3)
3625dfecf96Smrg(format-test "Siamese Cat" "~[Siamese~;Manx~;Persian~] Cat" 0)
3635dfecf96Smrg(setq *print-level* nil *print-length* 5)
3645dfecf96Smrg(format-test " print length = 5"
3655dfecf96Smrg  "~@[ print level = ~D~]~@[ print length = ~D~]" *print-level* *print-length*)
3665dfecf96Smrg(setq foo "Items:~#[ none~; ~S~; ~S and ~S~:;~@{ ~#[~;and ~]~S~^,~}~].")
3675dfecf96Smrg(format-test "Items: none." foo)
3685dfecf96Smrg(format-test "Items: FOO." foo 'foo)
3695dfecf96Smrg(format-test "Items: FOO and BAR." foo 'foo 'bar)
3705dfecf96Smrg(format-test "Items: FOO, BAR, and BAZ." foo 'foo 'bar 'baz)
3715dfecf96Smrg(format-test "Items: FOO, BAR, BAZ, and QUUX." foo 'foo 'bar 'baz 'quux)
3725dfecf96Smrg
3735dfecf96Smrg;; ~{...~}
3745dfecf96Smrg(format-test "The winners are: FRED HARRY JILL."
3755dfecf96Smrg  "The winners are:~{ ~S~}." '(fred harry jill))
3765dfecf96Smrg(format-test "Pairs: <A,1> <B,2> <C,3>." "Pairs:~{ <~S,~S>~}." '(a 1 b 2 c 3))
3775dfecf96Smrg(format-test "Pairs: <A,1> <B,2> <C,3>."
3785dfecf96Smrg  "Pairs:~:{ <~S,~S>~}." '((a 1) (b 2) (c 3)))
3795dfecf96Smrg(format-test "Pairs: <A,1> <B,2> <C,3>."
3805dfecf96Smrg  "Pairs:~:@{ <~S,~S>~}." '(a 1) '(b 2) '(c 3))
3815dfecf96Smrg
3825dfecf96Smrg;; ~<...~>
3835dfecf96Smrg(format-test "foo    bar" "~10<foo~;bar~>")
3845dfecf96Smrg(format-test "  foo  bar" "~10:<foo~;bar~>")
3855dfecf96Smrg(format-test "  foo bar " "~10:@<foo~;bar~>")
3865dfecf96Smrg(format-test "    foobar" "~10<foobar~>")
3875dfecf96Smrg(format-test "    foobar" "~10:<foobar~>")
3885dfecf96Smrg(format-test "foobar    " "~10@<foobar~>")
3895dfecf96Smrg(format-test "  foobar  " "~10:@<foobar~>")
3905dfecf96Smrg
3915dfecf96Smrg;; ~^
3925dfecf96Smrg(setq donestr "Done.~^  ~D warning~:P.~^  ~D error~:P.")
3935dfecf96Smrg(format-test "Done." donestr)
3945dfecf96Smrg(format-test "Done.  3 warnings." donestr 3)
3955dfecf96Smrg(format-test "Done.  1 warning.  5 errors." donestr 1 5)
3965dfecf96Smrg(format-test "/HOT .../HAMBURGER/ICE .../FRENCH ..."
3975dfecf96Smrg  "~:{/~S~^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
3985dfecf96Smrg(format-test "/HOT .../HAMBURGER .../ICE .../FRENCH"
3995dfecf96Smrg  "~:{/~S~:^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
4005dfecf96Smrg(format-test "/HOT .../HAMBURGER"
4015dfecf96Smrg  "~:{/~S~:#^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
4025dfecf96Smrg(setq tellstr "~@(~@[~R~]~^ ~A.~)")
4035dfecf96Smrg(format-test "Twenty-three" tellstr 23)
4045dfecf96Smrg(format-test " Losers." tellstr nil "losers")
4055dfecf96Smrg(format-test "Twenty-three losers." tellstr 23 "losers")
4065dfecf96Smrg(format-test "            FOO" "~15<~S~;~^~S~;~^~S~>" 'foo)
4075dfecf96Smrg(format-test "FOO         BAR" "~15<~S~;~^~S~;~^~S~>" 'foo 'bar)
4085dfecf96Smrg(format-test "FOO   BAR   BAZ" "~15<~S~;~^~S~;~^~S~>" 'foo 'bar 'baz)
4095dfecf96Smrg
4105dfecf96Smrg
4115dfecf96Smrg;; make-pathname			- function
4125dfecf96Smrg(equal-test #P"/public/games/chess.db"
4135dfecf96Smrg    #'make-pathname :directory '(:absolute "public" "games")
4145dfecf96Smrg		    :name "chess" :type "db")
4155dfecf96Smrg(equal-test #P"/etc/passwd" #'list* #P"/etc/passwd")
4165dfecf96Smrg(setq path (make-pathname :directory '(:absolute "public" "games")
4175dfecf96Smrg			  :name "chess" :type "db"))
4185dfecf96Smrg(eq-test path #'pathname path)
4195dfecf96Smrg(eq-test nil #'pathname-host path)
4205dfecf96Smrg(eq-test nil #'pathname-device path)
4215dfecf96Smrg(equal-test '(:absolute "public" "games") #'pathname-directory path)
4225dfecf96Smrg(equal-test "chess" #'pathname-name path)
4235dfecf96Smrg(equal-test "db" #'pathname-type path)
4245dfecf96Smrg(eq-test nil #'pathname-version path)
4255dfecf96Smrg(equal-test #P"/tmp/foo.txt" #'make-pathname :defaults "/tmp/foo.txt")
4265dfecf96Smrg
4275dfecf96Smrg#+xedit (equal-test #P"/tmp/foo.txt" #'pathname "///tmp///foo.txt")
4285dfecf96Smrg;; XXX changed to remove extra separators
4295dfecf96Smrg;; (equal-test #P"///tmp///foo.txt" #'pathname "///tmp///foo.txt")
4305dfecf96Smrg
4315dfecf96Smrg
4325dfecf96Smrg;; merge-pathnames			- function
4335dfecf96Smrg(equal-test #P"/tmp/foo.txt" #'merge-pathnames "/tmp/foo" "/tmp/foo.txt")
4345dfecf96Smrg(equal-test #P"/tmp/foo.txt" #'merge-pathnames "foo" "/tmp/foo.txt")
4355dfecf96Smrg(equal-test #P"/tmp/foo/bar.txt" #'merge-pathnames "foo/bar" "/tmp/foo.txt")
4365dfecf96Smrg
4375dfecf96Smrg;; namestring				- function
4385dfecf96Smrg(setq path (merge-pathnames "foo/bar" "/tmp/foo.txt"))
4395dfecf96Smrg(equal-test "/tmp/foo/bar.txt" #'namestring path)
4405dfecf96Smrg(equal-test "" #'host-namestring path)
4415dfecf96Smrg(equal-test "/tmp/foo/" #'directory-namestring path)
4425dfecf96Smrg(equal-test "bar.txt" #'file-namestring path)
4435dfecf96Smrg(equal-test "/tmp/foo/bar.txt" #'enough-namestring path)
4445dfecf96Smrg(equal-test "foo/bar.txt" #'enough-namestring path "/tmp/")
4455dfecf96Smrg(equal-test "bar.txt" #'enough-namestring path "/tmp/foo/")
4465dfecf96Smrg(equal-test "foo/bar.txt" #'enough-namestring path "/tmp/foo")
4475dfecf96Smrg
4485dfecf96Smrg;; parse-namestring			- function
4495dfecf96Smrg(equal-eval '(#P"foo" 3) '(multiple-value-list (parse-namestring "foo")))
4505dfecf96Smrg(equal-eval '(#P"foo" 0) '(multiple-value-list (parse-namestring #P"foo")))
4515dfecf96Smrg
4525dfecf96Smrg
4535dfecf96Smrg
4545dfecf96Smrg;; read					- function
4555dfecf96Smrg(setq is (make-string-input-stream " foo "))
4565dfecf96Smrg(eq-test t #'streamp is)
4575dfecf96Smrg(eq-test t #'input-stream-p is)
4585dfecf96Smrg(eq-test nil #'output-stream-p is)
4595dfecf96Smrg(eq-test 'foo #'read is)
4605dfecf96Smrg(eq-test t #'close is)
4615dfecf96Smrg(setq is (make-string-input-stream "xfooy" 1 4))
4625dfecf96Smrg(eq-test 'foo #'read is)
4635dfecf96Smrg(eq-test t #'close is)
4645dfecf96Smrg(setq is (make-string-input-stream ""))
4655dfecf96Smrg(eq-test nil #'read is nil)
4665dfecf96Smrg(eq-test 'end-of-string #'read is nil 'end-of-string)
4675dfecf96Smrg(close is)
4685dfecf96Smrg(error-test #'read is)
4695dfecf96Smrg(error-test #'read is nil)
4705dfecf96Smrg(error-test #'read is nil 'end-of-string)
4715dfecf96Smrg(eq-test t #'streamp is)
4725dfecf96Smrg(eq-test nil #'input-stream-p is)
4735dfecf96Smrg(eq-test nil #'streamp "test")
4745dfecf96Smrg(error-test #'input-stream-p "test")
4755dfecf96Smrg
4765dfecf96Smrg;; read-char				- function
4775dfecf96Smrg(setq is (make-string-input-stream "0123"))
4785dfecf96Smrg(setq test nil)
4795dfecf96Smrg(equal-eval '(#\0 #\1 #\2 #\3)
4805dfecf96Smrg  '(do ((c (read-char is) (read-char is nil 'the-end)))
4815dfecf96Smrg      ((not (characterp c)) test)
4825dfecf96Smrg   (setq test (append test (list c)))))
4835dfecf96Smrg(close is)
4845dfecf96Smrg(setq is (make-string-input-stream "abc"))
4855dfecf96Smrg(eql-test #\a #'read-char is)
4865dfecf96Smrg(eql-test #\b #'read-char is)
4875dfecf96Smrg(eql-test #\c #'read-char is)
4885dfecf96Smrg(error-test #'read-char is)
4895dfecf96Smrg(eq-test nil #'read-char is nil)
4905dfecf96Smrg(eq-test :end-of-string #'read-char is nil :end-of-string)
4915dfecf96Smrg(eq-test t #'close is)
4925dfecf96Smrg
4935dfecf96Smrg;; read-char-no-hang			- function
4945dfecf96Smrg(setq is (make-string-input-stream "0123"))
4955dfecf96Smrg(setq test nil)
4965dfecf96Smrg(equal-eval '(#\0 #\1 #\2 #\3)
4975dfecf96Smrg  '(do ((c (read-char-no-hang is) (read-char-no-hang is nil 'the-end)))
4985dfecf96Smrg      ((not (characterp c)) test)
4995dfecf96Smrg   (setq test (append test (list c)))))
5005dfecf96Smrg(close is)
5015dfecf96Smrg(setq is (make-string-input-stream "abc"))
5025dfecf96Smrg(eql-test #\a #'read-char-no-hang is)
5035dfecf96Smrg(eql-test #\b #'read-char-no-hang is)
5045dfecf96Smrg(eql-test #\c #'read-char-no-hang is)
5055dfecf96Smrg(error-test #'read-char-no-hang is)
5065dfecf96Smrg(eq-test nil #'read-char-no-hang is nil)
5075dfecf96Smrg(eq-test :end-of-string #'read-char-no-hang is nil :end-of-string)
5085dfecf96Smrg(eq-test t #'close is)
5095dfecf96Smrg#+(and xedit unix)
5105dfecf96Smrg(progn
5115dfecf96Smrg    ;; wait one second for input pooling every 0.1 seconds
5125dfecf96Smrg    (defun wait-for-cat ()
5135dfecf96Smrg	(let ((time 0.0))
5145dfecf96Smrg	    (loop
5155dfecf96Smrg		(and (listen is) (return))
5165dfecf96Smrg		(sleep 0.1)
5175dfecf96Smrg		(when (>= (incf time 0.1) 1.0)
5185dfecf96Smrg		    (format t "Cat is sleeping~%")
5195dfecf96Smrg		    (return)))))
5205dfecf96Smrg    (setq is (make-pipe "/bin/cat" :direction :io))
5215dfecf96Smrg    (equal-test "dog" #'write-line "dog" is)
5225dfecf96Smrg    (wait-for-cat)
5235dfecf96Smrg    (eql-test #\d #'read-char-no-hang is)
5245dfecf96Smrg    (eql-test #\o #'read-char-no-hang is)
5255dfecf96Smrg    (eql-test #\g #'read-char-no-hang is)
5265dfecf96Smrg    (eql-test #\Newline #'read-char-no-hang is)
5275dfecf96Smrg    (eq-test nil #'read-char-no-hang is)
5285dfecf96Smrg    (eq-test nil #'read-char-no-hang is)
5295dfecf96Smrg    (equal-test "mouse" #'write-line "mouse" is)
5305dfecf96Smrg    (wait-for-cat)
5315dfecf96Smrg    (eql-test #\m #'read-char-no-hang is)
5325dfecf96Smrg    (eql-test #\o #'read-char-no-hang is)
5335dfecf96Smrg    (eql-test #\u #'read-char-no-hang is)
5345dfecf96Smrg    (eql-test #\s #'read-char-no-hang is)
5355dfecf96Smrg    (eql-test #\e #'read-char-no-hang is)
5365dfecf96Smrg    (eql-test #\Newline #'read-char-no-hang is)
5375dfecf96Smrg    (eq-test nil #'read-char-no-hang is)
5385dfecf96Smrg    (eq-test t #'close is)
5395dfecf96Smrg    (error-test #'read-char-no-hang is)
5405dfecf96Smrg    (error-test #'read-char-no-hang is nil)
5415dfecf96Smrg    (error-test #'read-char-no-hang is nil t)
5425dfecf96Smrg)
5435dfecf96Smrg
5445dfecf96Smrg;; read-from-string			- function
5455dfecf96Smrg(equal-eval '(3 5)
5465dfecf96Smrg  '(multiple-value-list (read-from-string " 1 3 5" t nil :start 2)))
5475dfecf96Smrg(equal-eval '((a b c) 7)
5485dfecf96Smrg  '(multiple-value-list (read-from-string "(a b c)")))
5495dfecf96Smrg(error-test #'read-from-string "")
5505dfecf96Smrg(eq-test nil #'read-from-string "" nil)
5515dfecf96Smrg(eq-test 'end-of-file #'read-from-string "" nil 'end-of-file)
5525dfecf96Smrg
5535dfecf96Smrg;; read-line				- function
5545dfecf96Smrg(setq is (make-string-input-stream "line 1
5555dfecf96Smrgline 2"))
5565dfecf96Smrg(equal-eval '("line 1" nil) '(multiple-value-list (read-line is)))
5575dfecf96Smrg(equal-eval '("line 2" t) '(multiple-value-list (read-line is)))
5585dfecf96Smrg(error-test #'read-line is)
5595dfecf96Smrg(equal-eval '(nil t) '(multiple-value-list (read-line is nil)))
5605dfecf96Smrg(equal-eval '(end-of-string t)
5615dfecf96Smrg  '(multiple-value-list (read-line is nil 'end-of-string)))
5625dfecf96Smrg
5635dfecf96Smrg
5645dfecf96Smrg;; write				- function
5655dfecf96Smrg;; XXX several write options still missing
5665dfecf96Smrg(setq os (make-string-output-stream))
5675dfecf96Smrg(equal-test '(1 2 3 4) #'write '(1 2 3 4) :stream os)
5685dfecf96Smrg(equal-test "(1 2 3 4)" #'get-output-stream-string os)
5695dfecf96Smrg(eq-test t #'streamp os)
5705dfecf96Smrg(eq-test t #'output-stream-p os)
5715dfecf96Smrg(eq-test nil #'input-stream-p os)
5725dfecf96Smrg(equal-test '(:foo :bar) #'write '(:foo :bar) :case :downcase :stream os)
5735dfecf96Smrg(equal-test "(:foo :bar)" #'get-output-stream-string os)
5745dfecf96Smrg(equal-test '(:foo :bar) #'write '(:foo :bar) :case :capitalize :stream os)
5755dfecf96Smrg(equal-test "(:Foo :Bar)" #'get-output-stream-string os)
5765dfecf96Smrg(equal-test '(:foo :bar) #'write '(:foo :bar) :case :upcase :stream os)
5775dfecf96Smrg(equal-test "(:FOO :BAR)" #'get-output-stream-string os)
5785dfecf96Smrg(equal-test '(foo bar baz) #'write '(foo bar baz) :length 2 :stream os)
5795dfecf96Smrg(equal-test "(FOO BAR ...)" #'get-output-stream-string os)
5805dfecf96Smrg(equal-test '(foo (bar) baz) #'write '(foo (bar) baz) :level 1 :stream os)
5815dfecf96Smrg(equal-test "(FOO # BAZ)" #'get-output-stream-string os)
5825dfecf96Smrg(setq circle '#1=(1 #1#))
5835dfecf96Smrg(eq-test circle #'write circle :circle t :stream os)
5845dfecf96Smrg(equal-test "#1=(1 #1#)" #'get-output-stream-string os)
5855dfecf96Smrg(eql-test #\Space #'write #\Space :stream os)
5865dfecf96Smrg(equal-test "#\\Space" #'get-output-stream-string os)
5875dfecf96Smrg(eql-test #\Space #'write #\Space :escape nil :stream os)
5885dfecf96Smrg(equal-test " " #'get-output-stream-string os)
5895dfecf96Smrg(eq-test t #'close os)
5905dfecf96Smrg(eq-test nil #'output-stream-p os)
5915dfecf96Smrg(error-test #'output-stream-p "test")
5925dfecf96Smrg(error-test #'write 'foo :stream "bar")
5935dfecf96Smrg
5945dfecf96Smrg;; fresh-line				- function
5955dfecf96Smrg(setq os (make-string-output-stream))
5965dfecf96Smrg(equal-test "some text" #'write-string "some text" os)
5975dfecf96Smrg(eq-test t #'fresh-line os)
5985dfecf96Smrg(eq-test nil #'fresh-line os)
5995dfecf96Smrg(equal-test "more text" #'write-string "more text" os)
6005dfecf96Smrg(equal-test "some text
6015dfecf96Smrgmore text" #'get-output-stream-string os)
6025dfecf96Smrg(equal-test nil #'fresh-line os)
6035dfecf96Smrg(equal-test nil #'fresh-line os)
6045dfecf96Smrg(equal-test "" #'get-output-stream-string os)
6055dfecf96Smrg(close os)
6065dfecf96Smrg(error-test #'fresh-line 1)
6075dfecf96Smrg
6085dfecf96Smrg;; prin1				- function
6095dfecf96Smrg;;  (prin1 object stream) ==
6105dfecf96Smrg;;	(write object :stream stream :escape t)
6115dfecf96Smrg(setq p-os (make-string-output-stream) w-os (make-string-output-stream))
6125dfecf96Smrg(dolist (object (list #\a 1 "string" 2.5d0 '(a . b) '(a b c) #P"foo"
6135dfecf96Smrg		     *package* *standard-input* #c(1 2) #(1 2 3)
6145dfecf96Smrg		     (make-hash-table)))
6155dfecf96Smrg    (eq-test object #'prin1 object p-os)
6165dfecf96Smrg    (eq-test object #'write object :stream w-os :escape t)
6175dfecf96Smrg    (equal-test (get-output-stream-string p-os)
6185dfecf96Smrg	#'get-output-stream-string w-os))
6195dfecf96Smrg(close p-os)
6205dfecf96Smrg(close w-os)
6215dfecf96Smrg(error-test #'prin1 1 1)
6225dfecf96Smrg
6235dfecf96Smrg;; princ				- function
6245dfecf96Smrg;;  (princ object stream) ==
6255dfecf96Smrg;;	(write object :stream stream :escape nil :readably nil)
6265dfecf96Smrg;; XXX readably not yet implemented
6275dfecf96Smrg(setq p-os (make-string-output-stream) w-os (make-string-output-stream))
6285dfecf96Smrg(dolist (object (list #\a 1 "string" 2.5d0 '(a . b) '(a b c) #P"foo"
6295dfecf96Smrg		     *package* *standard-input* #c(1 2) #(1 2 3)
6305dfecf96Smrg		     (make-hash-table)))
6315dfecf96Smrg    (eq-test object #'princ object p-os)
6325dfecf96Smrg    (eq-test object #'write object :stream w-os :escape nil)
6335dfecf96Smrg    (equal-test (get-output-stream-string p-os)
6345dfecf96Smrg	#'get-output-stream-string w-os))
6355dfecf96Smrg(close p-os)
6365dfecf96Smrg(close w-os)
6375dfecf96Smrg(error-test #'princ 1 1)
6385dfecf96Smrg
6395dfecf96Smrg;; print				- function
6405dfecf96Smrg;;  (print object stream) ==
6415dfecf96Smrg;;	(progn
6425dfecf96Smrg;;	    (terpri stream)
6435dfecf96Smrg;;	    (write object :stream stream :escape t)
6445dfecf96Smrg;;	    (write-char #\Space stream))
6455dfecf96Smrg(setq p-os (make-string-output-stream) w-os (make-string-output-stream))
6465dfecf96Smrg(dolist (object (list #\a 1 "string" 2.5d0 '(a . b) '(a b c) #P"foo"
6475dfecf96Smrg		     *package* *standard-input* #c(1 2) #(1 2 3)
6485dfecf96Smrg		     (make-hash-table)))
6495dfecf96Smrg    (eq-test object #'print object p-os)
6505dfecf96Smrg    (progn
6515dfecf96Smrg	(eq-test nil #'terpri w-os)
6525dfecf96Smrg	(eq-test object #'write object :stream w-os :escape t)
6535dfecf96Smrg	(eql-test #\Space #'write-char #\Space w-os))
6545dfecf96Smrg    (equal-test (get-output-stream-string p-os)
6555dfecf96Smrg	#'get-output-stream-string w-os))
6565dfecf96Smrg(close p-os)
6575dfecf96Smrg(close w-os)
6585dfecf96Smrg(error-test #'print 1 1)
6595dfecf96Smrg
6605dfecf96Smrg;; terpri				- function
6615dfecf96Smrg(setq os (make-string-output-stream))
6625dfecf96Smrg(equal-test "some text" #'write-string "some text" os)
6635dfecf96Smrg(eq-test nil #'terpri os)
6645dfecf96Smrg(eq-test nil #'terpri os)
6655dfecf96Smrg(equal-test "more text" #'write-string "more text" os)
6665dfecf96Smrg(equal-test "some text
6675dfecf96Smrg
6685dfecf96Smrgmore text" #'get-output-stream-string os)
6695dfecf96Smrg(equal-test nil #'terpri os)
6705dfecf96Smrg(equal-test nil #'terpri os)
6715dfecf96Smrg(equal-test "
6725dfecf96Smrg
6735dfecf96Smrg" #'get-output-stream-string os)
6745dfecf96Smrg(close os)
6755dfecf96Smrg(error-test #'terpri 1)
6765dfecf96Smrg
6775dfecf96Smrg;; write-char				- function
6785dfecf96Smrg(equal-eval "a b"
6795dfecf96Smrg    '(with-output-to-string (s)
6805dfecf96Smrg	(write-char #\a s)
6815dfecf96Smrg	(write-char #\Space s)
6825dfecf96Smrg	(write-char #\b s)))
6835dfecf96Smrg(error-test #'write-char 1)
6845dfecf96Smrg
6855dfecf96Smrg;; write-line				- function
6865dfecf96Smrg(setq os (make-string-output-stream))
6875dfecf96Smrg(equal-test "text" #'write-line "text" os)
6885dfecf96Smrg(equal-test "text
6895dfecf96Smrg" #'get-output-stream-string os)
6905dfecf96Smrg(eql-test #\< #'write-char #\< os)
6915dfecf96Smrg(equal-test "text" #'write-line "text" os :start 1 :end 3)
6925dfecf96Smrg(eql-test #\> #'write-char #\> os)
6935dfecf96Smrg(equal-test "<ex
6945dfecf96Smrg>" #'get-output-stream-string os)
6955dfecf96Smrg(error-test #'write-line 1)
6965dfecf96Smrg(close os)
6975dfecf96Smrg
6985dfecf96Smrg;; write-string				- function
6995dfecf96Smrg(setq os (make-string-output-stream))
7005dfecf96Smrg(equal-test "text" #'write-string "text" os)
7015dfecf96Smrg(equal-test "text" #'get-output-stream-string os)
7025dfecf96Smrg(eql-test #\< #'write-char #\< os)
7035dfecf96Smrg(equal-test "text" #'write-string "text" os :start 1 :end 3)
7045dfecf96Smrg(eql-test #\> #'write-char #\> os)
7055dfecf96Smrg(equal-test "<ex>" #'get-output-stream-string os)
7065dfecf96Smrg(error-test #'write-string #\a)
7075dfecf96Smrg(close os)
7085dfecf96Smrg
7095dfecf96Smrg
7105dfecf96Smrg;; open					- function
7115dfecf96Smrg(setq name #P"delete-me.text")
7125dfecf96Smrg(bool-eval t '(setq file (open name :direction :output)))
7135dfecf96Smrg(equal-test "some text" #'write-line "some text" file)
7145dfecf96Smrg(close file)
7155dfecf96Smrg(equal-test "delete-me.text" #'file-namestring (truename name))
7165dfecf96Smrg(setq file (open name :direction :output :if-exists :rename))
7175dfecf96Smrg(equal-test "other text" #'write-line "other text" file)
7185dfecf96Smrg(close file)
7195dfecf96Smrg(equal-test "delete-me.text" #'file-namestring (truename name))
7205dfecf96Smrg;; Clisp returns the pathname if the file exists
7215dfecf96Smrg#+xedit (eq-test t #'delete-file name)
7225dfecf96Smrg#+clisp (bool-test t #'delete-file name)
7235dfecf96Smrg(setq backup
7245dfecf96Smrg	#+xedit "delete-me.text~"
7255dfecf96Smrg	#+clisp "delete-me.text%"
7265dfecf96Smrg	#+cmu "delete-me.text.BAK")
7275dfecf96Smrg(bool-test t #'delete-file backup)
7285dfecf96Smrg(eq-test nil #'delete-file name)
7295dfecf96Smrg(eq-test nil #'directory name)
7305dfecf96Smrg(eq-test nil #'directory backup)
7315dfecf96Smrg;; test append
7325dfecf96Smrg(with-open-file (s name :direction :output :if-exists :error)
7335dfecf96Smrg    (write-line "line 1" s))
7345dfecf96Smrg(with-open-file (s name :direction :output :if-exists :append)
7355dfecf96Smrg    (write-line "line 2" s))
7365dfecf96Smrg(with-open-file (s name :direction :input)
7375dfecf96Smrg    (equal-test "line 1" #'read-line s)
7385dfecf96Smrg    (equal-test "line 2" #'read-line s)
7395dfecf96Smrg    (eq-test 'eof #'read-line s nil 'eof)
7405dfecf96Smrg)
7415dfecf96Smrg(bool-test t #'delete-file name)
7425dfecf96Smrg;; test overwrite
7435dfecf96Smrg(with-open-file (s name :direction :output :if-exists :error)
7445dfecf96Smrg    (write-line "overwrite-me" s))
7455dfecf96Smrg(with-open-file (s name :direction :output :if-exists :overwrite)
7465dfecf96Smrg    (write-line "some-text" s))
7475dfecf96Smrg(with-open-file (s name :direction :input)
7485dfecf96Smrg    (equal-test "some-text" #'read-line s)
7495dfecf96Smrg    (eq-test 'eof #'read-line s nil 'eof))
7505dfecf96Smrg;; test check for file existence
7515dfecf96Smrg(eq-test nil #'open name :direction :output :if-exists nil)
7525dfecf96Smrg(error-test #'open name :direction :output :if-exists :error)
7535dfecf96Smrg(bool-test t #'delete-file name)
7545dfecf96Smrg;; test check for no file existence
7555dfecf96Smrg(eq-test nil #'open name :direction :output :if-does-not-exist nil)
7565dfecf96Smrg(error-test #'open name :direction :output :if-does-not-exist :error)
7575dfecf96Smrg#+xedit	;; test io -- not sure if this is the expected behaviour
7585dfecf96Smrg(progn
7595dfecf96Smrg    (with-open-file (s name :direction :io)
7605dfecf96Smrg	(write-line "foo" s)
7615dfecf96Smrg	(write-line "bar" s))
7625dfecf96Smrg    (with-open-file (s name :direction :io :if-exists :append)
7635dfecf96Smrg	(equal-test "foo" #'read-line s)
7645dfecf96Smrg	(equal-test "bar" #'read-line s)
7655dfecf96Smrg	(eq-test 'eof #'read-line s nil 'eof)
7665dfecf96Smrg	(write-line "baz" s))
7675dfecf96Smrg    (with-open-file (s name :direction :io :if-exists :append)
7685dfecf96Smrg	(equal-test "foo" #'read-line s)
7695dfecf96Smrg	(equal-test "bar" #'read-line s)
7705dfecf96Smrg	(equal-test "baz" #'read-line s)
7715dfecf96Smrg	(eq-test 'eof #'read-line s nil 'eof))
7725dfecf96Smrg    (bool-test t #'delete-file name)
7735dfecf96Smrg)
7745dfecf96Smrg
7755dfecf96Smrg;; delete-file				- function
7765dfecf96Smrg(eq-eval nil
7775dfecf96Smrg    '(with-open-file (s "delete-me.text" :direction :output :if-exists :error)))
7785dfecf96Smrg(eq-test t #'pathnamep (setq p (probe-file "delete-me.text")))
7795dfecf96Smrg(bool-test t #'delete-file p)
7805dfecf96Smrg(eq-test nil #'probe-file "delete-me.text")
7815dfecf96Smrg(bool-eval t
7825dfecf96Smrg    '(with-open-file (s "delete-me.text" :direction :output :if-exists :error)
7835dfecf96Smrg       (delete-file s)))
7845dfecf96Smrg(bool-test nil #'probe-file "delete-me.text")
7855dfecf96Smrg
7865dfecf96Smrg;; rename-file				- function
7875dfecf96Smrg(setq name "foo.bar")
7885dfecf96Smrg(bool-eval t '(setq file (open name :direction :output :if-exists :error)))
7895dfecf96Smrg(eq-test t #'close file)
7905dfecf96Smrg(setq result (multiple-value-list (rename-file name "bar.foo")))
7915dfecf96Smrg(eql-test 3 #'length result)
7925dfecf96Smrg(eq-test t #'pathnamep (first result))
7935dfecf96Smrg(eq-test t #'pathnamep (second result))
7945dfecf96Smrg(eq-test t #'pathnamep (third result))
7955dfecf96Smrg(equal-test (third result) #'truename "bar.foo")
7965dfecf96Smrg(eq-test nil #'directory name)
7975dfecf96Smrg(eq-test nil #'directory (second result))
7985dfecf96Smrg(equal-test (list (third result)) #'directory (third result))
7995dfecf96Smrg(error-test #'truename name)
8005dfecf96Smrg(error-test #'truename (second result))
8015dfecf96Smrg(eq-test nil #'probe-file name)
8025dfecf96Smrg(bool-test t #'probe-file (first result))
8035dfecf96Smrg(eq-test nil #'probe-file (second result))
8045dfecf96Smrg(bool-test t #'probe-file (third result))
8055dfecf96Smrg(bool-test t #'delete-file "bar.foo")
8065dfecf96Smrg(eq-test nil #'delete-file (third result))
8075dfecf96Smrg(eq-test nil #'delete-file (second result))
808