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

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

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

File size: 1.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jul 27 23:47:44 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  "~%" nil #.(string #\Newline))
11
12(deftest format.%.2
13  (loop for i from 0 to 100
14        for s1 = (make-string i :initial-element #\Newline)
15        for format-string = (format nil "~~~D%" i)
16        for s2 = (format nil format-string)
17        for fn = (eval `(formatter ,s2))
18        for s3 = (formatter-call-to-string fn)
19        unless (and (string= s1 s2) (string= s1 s3))
20        collect i)
21  nil)
22
23(def-format-test format.%.3
24  "~v%" (nil) #.(string #\Newline))
25
26(def-format-test format.%.4
27  "~V%" (1) #.(string #\Newline))
28
29(deftest format.%.5
30  (loop for i from 0 to 100
31        for s1 = (make-string i :initial-element #\Newline)
32        for s2 = (format nil "~v%" i)
33        unless (string= s1 s2)
34        collect i)
35  nil)
36
37(deftest formatter.%.5
38  (let ((fn (formatter "~v%")))
39    (loop for i from 0 to 100
40          for s1 = (make-string i :initial-element #\Newline)
41          for s2 = (formatter-call-to-string fn i)
42          unless (string= s1 s2)
43          collect i))
44  nil)
45
46(deftest format.%.6
47  (loop for i from 0 to (min (- call-arguments-limit 3) 100)
48        for args = (make-list i)
49        for s1 = (make-string i :initial-element #\Newline)
50        for s2 = (apply #'format nil "~#%" args)
51        unless (string= s1 s2)
52        collect i)
53  nil)
54
55(deftest formatter.%.6
56  (let ((fn (formatter "~#%")))
57    (loop for i from 0 to (min (- call-arguments-limit 3) 100)
58          for args = (make-list i)
59          for s1 = (make-string i :initial-element #\Newline)
60          for s2 = (with-output-to-string
61                     (stream)
62                     (assert (equal (apply fn stream args) args)))
63          unless (string= s1 s2)
64          collect i))
65  nil)
Note: See TracBrowser for help on using the repository browser.