1;;;; pp-test.scm
2
3(import (only chicken.pretty-print pp)
4        (only chicken.port with-output-to-string)
5	(only (chicken memory representation) block-ref))
6
7(define (pp->string thing)
8  (with-output-to-string (cut pp thing)))
9
10(define-syntax test
11  (syntax-rules ()
12    ((_ result exp)
13     (assert (equal? result exp)))))
14
15(test "\"\\\"foo\\\"\"\n" (pp->string "\"foo\""))
16(test "\"\\\\\\\"\"\n" (pp->string "\\\""))
17(test "\"\\\\\\\\\\\\\\\"\"\n" (pp->string "\\\\\\\""))
18(test "\"\\\"\\\"\\\"\"\n" (pp->string "\"\"\""))
19(test "\"\\n\\t\\r\\b\\a\\v\\f\"\n" (pp->string "\n\t\r\b\a\v\f"))
20(test "\\" "\\")                        ; XXX?
21(test "#<unbound value>\n" (pp->string (block-ref 'aardvark 0))) ;; Shouldn't crash
22