File: pp-test.scm

package info (click to toggle)
chicken 5.3.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,892 kB
  • sloc: ansic: 580,083; lisp: 71,987; tcl: 1,445; sh: 588; makefile: 60
file content (21 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;;;; pp-test.scm

(import (only chicken.pretty-print pp)
        (only chicken.port with-output-to-string)
	(only (chicken memory representation) block-ref))

(define (pp->string thing)
  (with-output-to-string (cut pp thing)))

(define-syntax test 
  (syntax-rules ()
    ((_ result exp)
     (assert (equal? result exp)))))

(test "\"\\\"foo\\\"\"\n" (pp->string "\"foo\""))
(test "\"\\\\\\\"\"\n" (pp->string "\\\""))
(test "\"\\\\\\\\\\\\\\\"\"\n" (pp->string "\\\\\\\""))
(test "\"\\\"\\\"\\\"\"\n" (pp->string "\"\"\""))
(test "\"\\n\\t\\r\\b\\a\\v\\f\"\n" (pp->string "\n\t\r\b\a\v\f"))
(test "\\" "\\")                        ; XXX?
(test "#<unbound value>\n" (pp->string (block-ref 'aardvark 0))) ;; Shouldn't crash