source: trunk/source/tests/ansi-tests/format-slash.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 4.0 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Aug 21 09:51:08 2004
4;;;; Contains: Tests for format directive ~/.../
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10(def-pprint-test format./.1
11  (format nil "~/pprint-linear/" 1)
12  "1")
13
14(def-pprint-test format./.2
15  (format nil "~/pprint-linear/" 2)
16  "2"
17  :pretty nil)
18
19(def-pprint-test format./.3
20  (format nil "~/pprint-linear/" '(17))
21  "17")
22
23(def-pprint-test format./.4
24  (format nil "~:/pprint-linear/" '(17))
25  "(17)")
26
27(def-pprint-test format./.5
28  (format nil "~@/pprint-linear/" 1)
29  "1")
30
31(def-pprint-test format./.6
32  (format nil "~@:/pprint-linear/" 1)
33  "1")
34
35(def-pprint-test format./.7
36  (format nil "~/PPRINT-LINEAR/" 1)
37  "1")
38
39(def-pprint-test format./.8
40  (format nil "~/pPrINt-lINeaR/" 1)
41  "1")
42
43(def-pprint-test format./.9
44  (progn
45    (setf (symbol-function 'FUNCTION-FOR-FORMAT-SLASH-9) #'pprint-linear)
46    (format nil "~/CL-TEST::FUNCTION-FOR-FORMAT-SLASH-9/" 1))
47  "1")
48
49;;; Single : doesn't mean it has to be exported
50(def-pprint-test format./.10
51  (progn
52    (setf (symbol-function 'FUNCTION-FOR-FORMAT-SLASH-10) #'pprint-linear)
53    (format nil "~/cl-test:FUNCTION-FOR-FORMAT-SLASH-10/" 1))
54  "1")
55
56(def-pprint-test format./.11
57  (progn
58    (setf (symbol-function '|FUNCTION:FOR::FORMAT:SLASH:11|) #'pprint-linear)
59    (format nil "~/cL-tESt:FUNCTION:FOR::FORMAT:SLASH:11/" 1))
60  "1")
61
62(def-pprint-test format./.12
63  (format nil "~<~/pprint-tabular/~:>" '((|M|)))
64  "M")
65
66(def-pprint-test format./.13
67  (format nil "~<~:/pprint-tabular/~:>" '((|M|)))
68  "(M)")
69
70(def-pprint-test format./.14
71  (format nil "~<~:@/pprint-tabular/~:>" '((|M|)))
72  "(M)")
73
74(def-pprint-test format./.15
75  (format nil "~<~@/pprint-tabular/~:>" '((|M|)))
76  "M")
77
78(def-pprint-test format./.16
79  (format nil "~<~4:/pprint-tabular/~:>" '((|M| |M|)))
80  "(M   M)")
81
82(def-pprint-test format./.17
83  (format nil "~<~v:/pprint-tabular/~:>" '(nil (|M| |M|)))
84  "(M               M)")
85
86(def-pprint-test format./.18
87  (format nil "~<~v:/pprint-tabular/~:>" '(3 (|M| |M|)))
88  "(M  M)")
89
90(declaim (special *expected-args*))
91
92(def-pprint-test format./.19
93  (progn
94   (setf (symbol-function 'function-for-format-slash-19)
95         #'(lambda (stream &rest args)
96             (assert (= (length args) (length *expected-args*)))
97             (assert (equal (car args) (car *expected-args*)))
98             (assert (if (cadr args) (cadr *expected-args*)
99                       (not (cadr *expected-args*))))
100             (assert (if (caddr args) (caddr *expected-args*)
101                       (not (caddr *expected-args*))))
102             (apply #'pprint-fill stream (subseq args 0 3))))
103   (list
104    (let ((*expected-args* '(1 nil nil)))
105      (format nil "~/cl-test::function-for-format-slash-19/" 1))
106    (let ((*expected-args* '(2 t nil)))
107      (format nil "~:/cl-test::function-for-format-slash-19/" 2))
108    (let ((*expected-args* '(3 nil t)))
109      (format nil "~@/cl-test::function-for-format-slash-19/" 3))
110    (let ((*expected-args* '(4 t t)))
111      (format nil "~:@/cl-test::function-for-format-slash-19/" 4))
112    (let ((*expected-args* '(5 t t)))
113      (format nil "~@:/cl-test::function-for-format-slash-19/" 5))
114    (let ((*expected-args* '(6 t t 18)))
115      (format nil "~18@:/cl-test::function-for-format-slash-19/" 6))
116    (let ((*expected-args* '(7 nil nil 19)))
117      (format nil "~v/cl-test::function-for-format-slash-19/" 19 7))
118    (let ((*expected-args* '(8 t nil #\X)))
119      (format nil "~'X:/cl-test::function-for-format-slash-19/" 8))
120    (let ((*expected-args* '(9 nil t #\,)))
121      (format nil "~',@/cl-test::function-for-format-slash-19/" 9))
122    (let ((*expected-args* '(10 nil t -1)))
123      (format nil "~-1@/cl-test::function-for-format-slash-19/" 10))
124    (let ((*expected-args* '(11 nil t 1 2 3 4 5 6 7 8 9 10)))
125      (format nil "~1,2,3,4,5,6,7,8,9,10@/cl-test::function-for-format-slash-19/" 11))
126    (let ((*expected-args* '(12 nil t 1 2 3 4 5 6 7 8 9 10)))
127      (format nil "~v,v,v,v,v,v,v,v,v,v@/cl-test::function-for-format-slash-19/" 1 2 3 4 5 6 7 8 9 10 12))
128    ))
129  ("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"))
130
131
132
133
134
Note: See TracBrowser for help on using the repository browser.