source: trunk/source/tests/ansi-tests/format-p.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: 1.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Oct 17 21:32:45 2004
4;;;; Contains: Tests of the ~P format directives
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10(def-format-test format.p.1
11  "~p" (1) "")
12
13(def-format-test format.p.2
14  "~P" (2) "s")
15
16(def-format-test format.p.3
17  "~p" (0) "s")
18
19(def-format-test format.p.4
20  "~P" (1.0) "s")
21
22(deftest format.p.5
23  (loop for x in *universe*
24        for s = (format nil "~p" x)
25        unless (or (eql x 1) (string= s "s"))
26        collect (list x s))
27  nil)
28
29(deftest formatter.p.5
30  (let ((fn (formatter "~p")))
31    (loop for x in *universe*
32          for s = (formatter-call-to-string fn x)
33          unless (or (eql x 1) (string= s "s"))
34          collect (list x s)))
35  nil)
36
37;;; :p
38
39(def-format-test format.p.6
40  "~D cat~:P" (1) "1 cat")
41
42(def-format-test format.p.7
43  "~D cat~:p" (2) "2 cats")
44
45(def-format-test format.p.8
46  "~D cat~:P" (0) "0 cats")
47
48(def-format-test format.p.9
49  "~D cat~:p" ("No") "No cats")
50
51;;; :@p
52
53(def-format-test format.p.10
54  "~D penn~:@P" (1) "1 penny")
55
56(def-format-test format.p.11
57  "~D penn~:@p" (2) "2 pennies")
58
59(def-format-test format.p.12
60  "~D penn~@:P" (0) "0 pennies")
61
62(def-format-test format.p.13
63  "~D penn~@:p" ("No") "No pennies")
64
65;;; @p
66
67(def-format-test format.p.14
68  "~@p" (1) "y")
69
70(def-format-test format.p.15
71  "~@P" (2) "ies")
72
73(def-format-test format.p.16
74  "~@p" (0) "ies")
75
76(def-format-test format.p.17
77  "~@P" (1.0) "ies")
78
79(deftest format.p.18
80  (loop for x in *universe*
81        for s = (format nil "~@p" x)
82        unless (or (eql x 1) (string= s "ies"))
83        collect (list x s))
84  nil)
85
86(deftest formatter.p.18
87  (let ((fn (formatter "~@P")))
88    (loop for x in *universe*
89          for s = (formatter-call-to-string fn x)
90          unless (or (eql x 1) (string= s "ies"))
91          collect (list x s)))
92  nil)
Note: See TracBrowser for help on using the repository browser.