Commit 03c49ece authored by pfdietz's avatar pfdietz

Convert format tests to combination format/formatter tests using a DEF-FORMAT-TEST macro

parent 81a36f58
......@@ -4,11 +4,10 @@
;;;; Contains: Tests of printing using the ~A directive
(in-package :cl-test)
(compile-and-load "printer-aux.lsp")
(deftest format.a.1
(with-standard-io-syntax
(format nil "~a" nil))
"NIL")
(def-format-test format.a.1
"~a" (nil) "NIL")
(deftest format.a.2
(with-standard-io-syntax
......@@ -22,19 +21,14 @@
(format nil "~a" nil)))
"Nil")
(deftest format.a.4
(format nil "~:a" nil)
"()")
(def-format-test format.a.4
"~:a" (nil) "()")
(deftest format.a.5
(with-standard-io-syntax
(format nil "~:A" '(nil)))
"(NIL)")
(def-format-test format.a.5
"~:A" ('(nil)) "(NIL)")
(deftest format.a.6
(with-standard-io-syntax
(format nil "~:A" #(nil)))
"#(NIL)")
(def-format-test format.a.6
"~:A" (#(nil)) "#(NIL)")
(deftest format.a.7
(loop for c across +standard-chars+
......@@ -167,69 +161,49 @@
" ()"
" ()")
(deftest format.a.15
(with-standard-io-syntax
(format nil "~vA" nil nil))
"NIL")
(def-format-test format.a.15
"~vA" (nil nil) "NIL")
(deftest format.a.16
(with-standard-io-syntax
(format nil "~v:A" nil nil))
"()")
(def-format-test format.a.16
"~v:A" (nil nil) "()")
(deftest format.a.17
(with-standard-io-syntax
(format nil "~@A" nil))
"NIL")
(def-format-test format.a.17
"~@A" (nil) "NIL")
(deftest format.a.18
(with-standard-io-syntax
(format nil "~v@A" nil nil))
"NIL")
(def-format-test format.a.18
"~v@A" (nil nil) "NIL")
(deftest format.a.19
(with-standard-io-syntax
(format nil "~v:@a" nil nil))
"()")
(def-format-test format.a.19
"~v:@a" (nil nil) "()")
(deftest format.a.20
(with-standard-io-syntax
(format nil "~v@:a" nil nil))
"()")
(def-format-test format.a.20
"~v@:a" (nil nil) "()")
;;; With colinc specified
(deftest format.a.21
(format nil "~3,1a" nil)
"NIL")
(def-format-test format.a.21
"~3,1a" (nil) "NIL")
(deftest format.a.22
(format nil "~4,3a" nil)
"NIL ")
(def-format-test format.a.22
"~4,3a" (nil) "NIL ")
(deftest format.a.23
(format nil "~3,3@a" nil)
"NIL")
(def-format-test format.a.23
"~3,3@a" (nil) "NIL")
(deftest format.a.24
(format nil "~4,4@a" nil)
" NIL")
(def-format-test format.a.24
"~4,4@a" (nil) " NIL")
(deftest format.a.25
(format nil "~5,3@a" nil)
" NIL")
(def-format-test format.a.25
"~5,3@a" (nil) " NIL")
(deftest format.a.26
(format nil "~5,3A" nil)
"NIL ")
(def-format-test format.a.26
"~5,3A" (nil) "NIL ")
(deftest format.a.27
(format nil "~7,3@a" nil)
" NIL")
(def-format-test format.a.27
"~7,3@a" (nil) " NIL")
(deftest format.a.28
(format nil "~7,3A" nil)
"NIL ")
(def-format-test format.a.28
"~7,3A" (nil) "NIL ")
;;; With minpad
......@@ -252,65 +226,51 @@
"ABC "
"ABC "))
(deftest format.a.30
(format nil "~3,,+2A" "ABC")
"ABC ")
(def-format-test format.a.30
"~3,,+2A" ("ABC") "ABC ")
(deftest format.a.31
(format nil "~3,,0A" "ABC")
"ABC")
(def-format-test format.a.31
"~3,,0A" ("ABC") "ABC")
(deftest format.a.32
(format nil "~3,,-1A" "ABC")
"ABC")
(def-format-test format.a.32
"~3,,-1A" ("ABC") "ABC")
(deftest format.a.33
(format nil "~3,,0A" "ABCD")
"ABCD")
(def-format-test format.a.33
"~3,,0A" ("ABCD") "ABCD")
(deftest format.a.34
(format nil "~3,,-1A" "ABCD")
"ABCD")
(def-format-test format.a.34
"~3,,-1A" ("ABCD") "ABCD")
;;; With padchar
(deftest format.a.35
(format nil "~4,,,'XA" "AB")
"ABXX")
(def-format-test format.a.35
"~4,,,'XA" ("AB") "ABXX")
(deftest format.a.36
(format nil "~4,,,a" "AB")
"AB ")
(def-format-test format.a.36
"~4,,,a" ("AB") "AB ")
(deftest format.a.37
(format nil "~4,,,'X@a" "AB")
"XXAB")
(def-format-test format.a.37
"~4,,,'X@a" ("AB") "XXAB")
(deftest format.a.38
(format nil "~4,,,@A" "AB")
" AB")
(def-format-test format.a.38
"~4,,,@A" ("AB") " AB")
(deftest format.a.39
(format nil "~10,,,vA" nil "abcde")
"abcde ")
(def-format-test format.a.39
"~10,,,vA" (nil "abcde") "abcde ")
(deftest format.a.40
(format nil "~10,,,v@A" nil "abcde")
" abcde")
(def-format-test format.a.40
"~10,,,v@A" (nil "abcde") " abcde")
(deftest format.a.41
(format nil "~10,,,va" #\* "abcde")
"abcde*****")
(def-format-test format.a.41
"~10,,,va" (#\* "abcde") "abcde*****")
(deftest format.a.42
(format nil "~10,,,v@a" #\* "abcde")
"*****abcde")
(def-format-test format.a.42
"~10,,,v@a" (#\* "abcde") "*****abcde")
;;; Other tests
(deftest format.a.43
(format nil "~3,,vA" nil "ABC")
"ABC")
(def-format-test format.a.43
"~3,,vA" (nil "ABC") "ABC")
(deftest format.a.44
(loop for i from 0 to 6
......@@ -334,60 +294,46 @@
" ABC"
" ABC"))
(deftest format.a.45
(format nil "~4,,va" -1 "abcd")
"abcd")
(def-format-test format.a.45
"~4,,va" (-1 "abcd") "abcd")
(deftest format.a.46
(format nil "~5,vA" nil "abc")
"abc ")
(def-format-test format.a.46
"~5,vA" (nil "abc") "abc ")
(deftest format.a.47
(format nil "~5,vA" 3 "abc")
"abc ")
(def-format-test format.a.47
"~5,vA" (3 "abc") "abc ")
(deftest format.a.48
(format nil "~5,v@A" 3 "abc")
" abc")
(def-format-test format.a.48
"~5,v@A" (3 "abc") " abc")
;;; # parameters
(deftest format.a.49
(format nil "~#A" "abc" nil nil nil)
"abc ")
(def-format-test format.a.49
"~#A" ("abc" nil nil nil) "abc ")
(deftest format.a.50
(format nil "~#@a" "abc" nil nil nil nil nil)
" abc")
(def-format-test format.a.50
"~#@a" ("abc" nil nil nil nil nil) " abc")
(deftest format.a.51
(format nil "~5,#a" "abc" nil nil nil)
"abc ")
(def-format-test format.a.51
"~5,#a" ("abc" nil nil nil) "abc ")
(deftest format.a.52
(format nil "~5,#@A" "abc" nil nil nil)
" abc")
(def-format-test format.a.52
"~5,#@A" ("abc" nil nil nil) " abc")
(deftest format.a.53
(format nil "~4,#A" "abc" nil nil)
"abc ")
(def-format-test format.a.53
"~4,#A" ("abc" nil nil) "abc ")
(deftest format.a.54
(format nil "~4,#@A" "abc" nil nil)
" abc")
(def-format-test format.a.54
"~4,#@A" ("abc" nil nil) " abc")
(deftest format.a.55
(format nil "~#,#A" "abc" nil nil nil)
"abc ")
(def-format-test format.a.55
"~#,#A" ("abc" nil nil nil) "abc ")
(deftest format.a.56
(format nil "~#,#@A" "abc" nil nil nil)
" abc")
(def-format-test format.a.56
"~#,#@A" ("abc" nil nil nil) " abc")
(deftest format.a.57
(format nil "~-100A" "xyz")
"xyz")
(def-format-test format.a.57
"~-100A" ("xyz") "xyz")
(deftest format.a.58
(format nil "~-100000000000000000000a" "xyz")
"xyz")
(def-format-test format.a.58
"~-100000000000000000000a" ("xyz") "xyz")
......@@ -5,23 +5,17 @@
(in-package :cl-test)
(deftest format.&.1
(format nil "~0&")
"")
(def-format-test format.&.1
"~0&" nil "")
(deftest format.&.2
(format nil "~&")
"")
(def-format-test format.&.2
"~&" nil "")
(deftest format.&.3
(format nil "X~&")
"X
")
(def-format-test format.&.3
"X~&" nil #.(concatenate 'string "X" (string #\Newline)))
(deftest format.&.4
(format nil "X~%~&")
"X
")
(def-format-test format.&.4
"X~%~&" nil #.(concatenate 'string "X" (string #\Newline)))
(deftest format.&.5
(loop for i from 1 to 100
......@@ -41,14 +35,11 @@
collect i)
nil)
(deftest format.&.7
(format nil "~v&" nil)
"")
(def-format-test format.&.7
"~v&" (nil) "")
(deftest format.&.8
(format nil "X~v&" nil)
"X
")
(def-format-test format.&.8
"X~v&" (nil) #.(concatenate 'string "X" (string #\Newline)))
(deftest format.&.9
(loop for i from 1 to 100
......@@ -67,21 +58,17 @@
collect i)
nil)
(deftest format.&.11
(format nil "X~V%" 0)
"X")
(def-format-test format.&.11
"X~V%" (0) "X")
(deftest format.&.12
(format nil "X~#%")
"X")
(def-format-test format.&.12
"X~#%" nil "X")
(deftest format.&.13
(format nil "X~#%" 'a 'b 'c)
"X
(def-format-test format.&.13
"X~#%" ('a 'b 'c) #.(let ((nl (string #\Newline)))
(concatenate 'string "X" nl nl nl)))
")
......
......@@ -244,21 +244,17 @@
;;; NIL arguments
(deftest format.b.14
(format nil "~vb" nil #b110100)
"110100")
(def-format-test format.b.14
"~vb" (nil #b110100) "110100")
(deftest format.b.15
(format nil "~6,vB" nil #b100)
" 100")
(def-format-test format.b.15
"~6,vB" (nil #b100) " 100")
(deftest format.b.16
(format nil "~,,v:b" nil #b10011)
"10,011")
(def-format-test format.b.16
"~,,v:b" (nil #b10011) "10,011")
(deftest format.b.17
(format nil "~,,'*,v:B" nil #b10110)
"10*110")
(def-format-test format.b.17
"~,,'*,v:B" (nil #b10110) "10*110")
;;; When the argument is not an integer, print as if using ~A and base 10
......@@ -358,25 +354,20 @@
"+1100100010"
"+1100100010")
(deftest format.b.25
(format nil "~+10b" #b1101)
" 1101")
(def-format-test format.b.25
"~+10b" (#b1101) " 1101")
(deftest format.b.26
(format nil "~+10@B" #b1101)
" +1101")
(def-format-test format.b.26
"~+10@B" (#b1101) " +1101")
(deftest format.b.27
(format nil "~-1b" #b1101)
"1101")
(def-format-test format.b.27
"~-1b" (#b1101) "1101")
(deftest format.b.28
(format nil "~-1000000000000000000B" #b1101)
"1101")
(def-format-test format.b.28
"~-1000000000000000000B" (#b1101) "1101")
(deftest format.b.29
(format nil "~vb" (1- most-negative-fixnum) #b1101)
"1101")
(def-format-test format.b.29
"~vb" ((1- most-negative-fixnum) #b1101) "1101")
;;; Randomized test
......
<
......@@ -7,43 +7,33 @@
(compile-and-load "printer-aux.lsp")
(deftest format.{.1
(format nil "~{~
~}" nil)
"")
(def-format-test format.{.1
(concatenate 'string "~{~" (string #\Newline) "~}")
(nil) "")
(deftest format.{.1a
(format nil "~{~}" "" nil)
"")
(def-format-test format.{.1a
"~{~}" ("" nil) "")
(deftest format.{.1b
(format nil "~0{~}" "" '(1 2 3))
"")
(def-format-test format.{.1b
"~0{~}" ("" '(1 2 3)) "")
(deftest format.{.2
(format nil "~{ ~}" nil)
"")
(def-format-test format.{.2
"~{ ~}" (nil) "")
(deftest format.{.3
(format nil "~{X Y Z~}" nil)
"")
(def-format-test format.{.3
"~{X Y Z~}" (nil) "")
(deftest format.{.4
(format nil "~{~A~}" '(1 2 3 4))
"1234")
(def-format-test format.{.4
"~{~A~}" ('(1 2 3 4)) "1234")
(deftest format.{.5
(format nil "~{~{~A~}~}" '((1 2 3)(4 5)(6 7 8)))
"12345678")
(def-format-test format.{.5
"~{~{~A~}~}" ('((1 2 3)(4 5)(6 7 8))) "12345678")
(deftest format.{.6
(format nil "~{~1{~A~}~}" '((1 2 3)(4 5)(6 7 8)))
"146")
(def-format-test format.{.6
"~{~1{~A~}~}" ('((1 2 3)(4 5)(6 7 8))) "146")
(deftest format.{.7
(format nil "~1{~
~}" nil)
"")
(def-format-test format.{.7
(concatenate 'string "~1{~" (string #\Newline) "~}") (nil) "")
(deftest format.{.8
(loop for i from 0 to 10
......@@ -52,20 +42,17 @@
collect (list i s))
nil)
(deftest format.{.9
(format nil "~#{~A~}" '(1 2 3 4 5 6 7) nil nil nil)
"1234")
(def-format-test format.{.9
"~#{~A~}" ('(1 2 3 4 5 6 7) nil nil nil) "1234")
;;; (missing tests involved ~^ and have been moved to format-circumflex.lsp
;;; and renamed.)
(deftest format.{.15
(format nil "~0{~}" "~A" '(1 2 3))
"")
(def-format-test format.{.15
"~0{~}" ("~A" '(1 2 3)) "")
(deftest format.{.16
(format nil "~1{~}" "~A" '(4 5 6))
"4")
(def-format-test format.{.16
"~1{~}" ("~A" '(4 5 6)) "4")
(deftest format.{.17
(format nil "~{~}" (formatter "") nil)
......@@ -83,101 +70,79 @@
(format nil "~3{~}" (formatter "~A") '(1 2 3 4))
"123")
(deftest format.{.21
(format nil "~V{~}" 2 "~A" '(1 2 3 4 5))
"12")
(def-format-test format.{.21
"~V{~}" (2 "~A" '(1 2 3 4 5)) "12")
(deftest format.{.22
(format nil "~#{~}" "~A" '(1 2 3 4 5))
"12")
(def-format-test format.{.22
"~#{~}" ("~A" '(1 2 3 4 5)) "12")
(deftest format.{.23
(format nil "~{FOO~:}" nil)
"FOO")
(def-format-test format.{.23
"~{FOO~:}" (nil) "FOO")
(deftest format.{.24
(format nil "~{~A~:}" '(1))
"1")
(def-format-test format.{.24
"~{~A~:}" ('(1)) "1")
(deftest format.{.25
(format nil "~{~A~:}" '(1 2))
"12")
(def-format-test format.{.25
"~{~A~:}" ('(1 2)) "12")
(deftest format.{.26
(format nil "~{~A~:}" '(1 2 3))
"123")
(def-format-test format.{.26
"~{~A~:}" ('(1 2 3)) "123")
(deftest format.{.27
(format nil "~0{FOO~:}" nil)
"")
(def-format-test format.{.27
"~0{FOO~:}" (nil) "")
(deftest format.{.28
(format nil "~V{FOO~:}" 0 nil)
"")
(def-format-test format.{.28
"~V{FOO~:}" (0 nil) "")
(deftest format.{.29
(format nil "~1{FOO~:}" nil)
"FOO")
(def-format-test format.{.29
"~1{FOO~:}" (nil) "FOO")
(deftest format.{.30
(format nil "~2{FOO~:}" nil)
"FOO")
(def-format-test format.{.30
"~2{FOO~:}" (nil) "FOO")
(deftest format.{.31
(format nil "~2{~
~:}" nil)
"")
(def-format-test format.{.31
(concatenate 'string "~2{~" (string #\Newline) "~:}")
(nil) "")
(deftest format.{.32
(format nil "~2{FOO~}" nil)
"")
(def-format-test format.{.32
"~2{FOO~}" (nil) "")
(deftest format.{.33
(format nil "~v{~a~}" nil '(1 2 3 4 5 6 7))
"1234567")
(def-format-test format.{.33
"~v{~a~}" (nil '(1 2 3 4 5 6 7)) "1234567")
;;; ~:{ ... ~}
(deftest format.\:{.1
(format nil "~:{(~A ~A)~}" '((1 2 3)(4 5)(6 7 8)))
"(1 2)(4 5)(6 7)")
(def-format-test format.\:{.1
"~:{(~A ~A)~}" ('((1 2 3)(4 5)(6 7 8))) "(1 2)(4 5)(6 7)")
(deftest format.\:{.2
(format nil "~:{~
~}" nil)
"")
(def-format-test format.\:{.2
(concatenate 'string "~:{~" (string #\Newline) "~}")
(nil) "")
(deftest format.\:{.3
(format nil "~:{~}" "" nil)
"")
(def-format-test format.\:{.3
"~:{~}" ("" nil) "")
(deftest format.\:{.4
(format nil "~:{~}" "~A" nil)
"")
(def-format-test format.\:{.4
"~:{~}" ("~A" nil) "")
(deftest format.\:{.5
(format nil "~:{~}" "X" '(nil (1 2) (3)))
"XXX")
(def-format-test format.\:{.5
"~:{~}" ("X" '(nil (1 2) (3))) "XXX")
(deftest format.\:{.6
(format nil "~:{~}" (formatter "~A") '((1 2) (3) (4 5 6)))
"134")
(deftest format.\:{.7
(format nil "~0:{XYZ~}" '((1)))
"")
(def-format-test format.\:{.7
"~0:{XYZ~}" ('((1))) "")
(deftest format.\:{.8
(format nil "~2:{XYZ~}" '((1)))
"XYZ")
(def-format-test format.\:{.8
"~2:{XYZ~}" ('((1))) "XYZ")
(deftest format.\:{.9
(format nil "~2:{~A~}" '((1) (2)))
"12")
(def-format-test format.\:{.9
"~2:{~A~}" ('((1) (2))) "12")
(deftest format.\:{.10
(format nil "~2:{~A~}" '((1 X) (2 Y) (3 Z)))
"12")
(def-format-test format.\:{.10
"~2:{~A~}" ('((1 X) (2 Y) (3 Z))) "12")
(deftest format.\:{.11
(loop for i from 0 to 10 collect
......@@ -185,17 +150,14 @@
("" "1" "12" "123" "1234" "12345"
"123456" "123456" "123456" "123456" "123456"))
(deftest format.\:{.12
(format nil "~V:{X~}" nil '((1) (2) (3) nil (5)))
"XXXXX")
(def-format-test format.\:{.12
"~V:{X~}" (nil '((1) (2) (3) nil (5))) "XXXXX")
(deftest format.\:{.13
(format nil "~#:{~A~}" '((1) (2) (3) (4) (5)) 'foo 'bar)
"123")
(def-format-test format.\:{.13
"~#:{~A~}" ('((1) (2) (3) (4) (5)) 'foo 'bar) "123")
(deftest format.\:{.14
(format nil "~:{~A~:}" '((1 X) (2 Y) (3) (4 A B)))
"1234")
(def-format-test format.\:{.14
"~:{~A~:}" ('((1 X) (2 Y) (3) (4 A B))) "1234")
(deftest format.\:{.15
(loop for i from 0 to 10 collect
......@@ -203,59 +165,45 @@
("" "1" "12" "123" "1234" "1234"
"1234" "1234" "1234" "1234" "1234"))
(deftest format.\:{.16
(format nil "~:{ABC~:}" '(nil))
"ABC")
(def-format-test format.\:{.16
"~:{ABC~:}" ('(nil)) "ABC")
(deftest format.\:{.17
(format nil "~v:{ABC~:}" nil '(nil))
"ABC")
(def-format-test format.\:{.17
"~v:{ABC~:}" (nil '(nil)) "ABC")
;;; Tests of ~@{ ... ~}
(deftest format.@{.1
(format nil "~@{~
~}")
"")
(def-format-test format.@{.1
(concatenate 'string "~@{~" (string #\Newline) "~}")
nil "")
(deftest format.@{.1A
(format nil "~@{~}" "")
"")
(def-format-test format.@{.1A
"~@{~}" ("") "")
(deftest format.@{.2
(format nil "~@{ ~}")
"")
(def-format-test format.@{.2
"~@{ ~}" nil "")
(deftest format.@{.3
(with-standard-io-syntax
(let ((*print-readably* nil))
(format nil "~@{X ~A Y Z~}" nil)))
"X NIL Y Z")
(def-format-test format.@{.3
"~@{X ~A Y Z~}" (nil) "X NIL Y Z")
(deftest format.@{.4
(format nil "~@{~A~}" 1 2 3 4)
"1234")
(def-format-test format.@{.4
"~@{~A~}" (1 2 3 4) "1234")
(deftest format.@{.5
(format nil "~@{~{~A~}~}" '(1 2 3) '(4 5) '(6 7 8))
"12345678")
(def-format-test format.@{.5
"~@{~{~A~}~}" ('(1 2 3) '(4 5) '(6 7 8)) "12345678")
(deftest format.@{.6
(format nil "~@{~1{~A~}~}" '(1 2 3) '(4 5) '(6 7 8))
"146")
(def-format-test format.@{.6