format-question.lsp 827 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Oct 17 20:08:18 2004
;;;; Contains: Tests of the ~? and ~@? format directives

(in-package :cl-test)

(compile-and-load "printer-aux.lsp")

10 11
(def-format-test format.?.1
  "~?" ("" nil) "")
12

13 14
(def-format-test format.?.2
  "~?" ("~A" '(1)) "1")
15

16 17
(def-format-test format.?.3
  "~?" ("" '(1)) "")
18

19 20
(def-format-test format.?.4
  "~? ~A" ("" '(1) 2) " 2")
21

22 23
(def-format-test format.?.5
  "a~?z" ("b~?y" '("c~?x" ("~A" (1)))) "abc1xyz")
24 25 26

;;; Tests of ~@?

27 28
(def-format-test format.@?.1
  "~@?" ("") "")
29

30 31
(def-format-test format.@?.2
  "~@?" ("~A" 1) "1")
32

33 34
(def-format-test format.@?.3
  "~@? ~A" ("<~A>" 1 2) "<1> 2")
35

36 37
(def-format-test format.@?.4
  "a~@?z" ("b~@?y" "c~@?x" "~A" 1) "abc1xyz")
38

39 40
(def-format-test format.@?.5
  "~{~A~@?~A~}" ('(1 "~4*" 2 3 4 5 6)) "16")