source: trunk/source/tests/ansi-tests/format-ampersand.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: 2.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jul 27 23:52:20 2004
4;;;; Contains: Tests of format with ~& directive
5
6(in-package :cl-test)
7(compile-and-load "printer-aux.lsp")
8
9(def-format-test format.&.1
10  "~0&" nil "")
11
12(def-format-test format.&.2
13  "~&" nil "")
14
15(def-format-test format.&.3
16  "X~&" nil #.(concatenate 'string "X" (string #\Newline)))
17
18(def-format-test format.&.4
19  "X~%~&" nil #.(concatenate 'string "X" (string #\Newline)))
20
21(deftest format.&.5
22  (loop for i from 1 to 100
23        for s1 = (make-string (1- i) :initial-element #\Newline)
24        for format-string = (format nil "~~~D&" i)
25        for s2 = (format nil format-string)
26        unless (string= s1 s2)
27        collect i)
28  nil)
29
30(deftest formatter.&.5
31  (loop for i from 1 to 100
32        for s1 = (make-string (1- i) :initial-element #\Newline)
33        for format-string = (format nil "~~~D&" i)
34        for fn = (eval `(formatter ,format-string))
35        for s2 = (formatter-call-to-string fn)
36        unless (string= s1 s2)
37        collect i)
38  nil)
39
40(deftest format.&.6
41  (loop for i from 1 to 100
42        for s1 = (concatenate 'string
43                              "X"
44                              (make-string i :initial-element #\Newline))
45        for format-string = (format nil "X~~~D&" i)
46        for s2 = (format nil format-string)
47        unless (string= s1 s2)
48        collect i)
49  nil)
50
51(deftest formatter.&.6
52  (loop for i from 1 to 100
53        for s1 = (concatenate 'string
54                              "X"
55                              (make-string i :initial-element #\Newline))
56        for format-string = (format nil "X~~~D&" i)
57        for fn = (eval `(formatter ,format-string))
58        for s2 = (formatter-call-to-string fn)
59        unless (string= s1 s2)
60        collect i)
61  nil)
62
63(def-format-test format.&.7
64  "~v&" (nil) "")
65
66(def-format-test format.&.8
67  "X~v&" (nil) #.(concatenate 'string "X" (string #\Newline)))
68
69(deftest format.&.9
70  (loop for i from 1 to 100
71        for s1 = (make-string (1- i) :initial-element #\Newline)
72        for s2 = (format nil "~V&" i)
73        unless (string= s1 s2)
74        collect i)
75  nil)
76
77(deftest formatter.&.9
78  (let ((fn (formatter "~V&")))
79    (loop for i from 1 to 100
80          for s1 = (make-string (1- i) :initial-element #\Newline)
81          for s2 = (formatter-call-to-string fn i)
82          unless (string= s1 s2)
83          collect i))
84  nil)
85
86(deftest format.&.10
87  (loop for i from 1 to (min (- call-arguments-limit 3) 100)
88        for s1 = (make-string (1- i) :initial-element #\Newline)
89        for args = (make-list i)
90        for s2 = (apply #'format nil "~#&" args)
91        unless (string= s1 s2)
92        collect i)
93  nil)
94
95(deftest formatter.&.10
96  (let ((fn (formatter "~#&")))
97    (loop for i from 1 to (min (- call-arguments-limit 3) 100)
98          for s1 = (make-string (1- i) :initial-element #\Newline)
99          for args = (loop for j below i collect j)
100          for s2 = (with-output-to-string
101                     (stream)
102                     (assert (equal (apply fn stream args) args)))
103          unless (string= s1 s2)
104          collect i))
105  nil)
106
107(def-format-test format.&.11
108  "X~V%" (0) "X")
109
110(def-format-test format.&.12
111  "X~#%" nil "X")
112
113(def-format-test format.&.13
114  "X~#%" ('a 'b 'c) #.(let ((nl (string #\Newline)))
115                        (concatenate 'string "X" nl nl nl))
116  3)
Note: See TracBrowser for help on using the repository browser.