Commit d0225ecd authored by pfdietz's avatar pfdietz
Browse files

More formatter tests for ~{

parent 04e0ea80
......@@ -42,6 +42,14 @@
collect (list i s))
nil)
(deftest formatter.{.8
(let ((fn (formatter "~V{~A~}")))
(loop for i from 0 to 10
for s = (formatter-call-to-string fn i '(1 2 3 4 5 6 7 8 9 0))
unless (string= s (subseq "1234567890" 0 i))
collect (list i s)))
nil)
(def-format-test format.{.9
"~#{~A~}" ('(1 2 3 4 5 6 7) nil nil nil) "1234" 3)
......@@ -150,6 +158,13 @@
("" "1" "12" "123" "1234" "12345"
"123456" "123456" "123456" "123456" "123456"))
(deftest formatter.\:{.11
(let ((fn (formatter "~v:{~A~}")))
(loop for i from 0 to 10 collect
(formatter-call-to-string fn i '((1) (2) (3 X) (4 Y Z) (5) (6)))))
("" "1" "12" "123" "1234" "12345"
"123456" "123456" "123456" "123456" "123456"))
(def-format-test format.\:{.12
"~V:{X~}" (nil '((1) (2) (3) nil (5))) "XXXXX")
......@@ -165,6 +180,13 @@
("" "1" "12" "123" "1234" "1234"
"1234" "1234" "1234" "1234" "1234"))
(deftest formatter.\:{.15
(let ((fn (formatter "~v:{~A~:}")))
(loop for i from 0 to 10 collect
(formatter-call-to-string fn i '((1 X) (2 Y) (3) (4 A B)))))
("" "1" "12" "123" "1234" "1234"
"1234" "1234" "1234" "1234" "1234"))
(def-format-test format.\:{.16
"~:{ABC~:}" ('(nil)) "ABC")
......@@ -212,6 +234,18 @@
("" "1" "12" "123" "1234" "12345"
"123456" "1234567" "12345678" "123456789" "12345678910"))
(deftest formatter.@{.10
(let ((fn (formatter "~v@{~A~}")))
(loop for i from 0 to 10
for x = nil then (cons i x)
for rest = (list 'a 'b 'c)
collect
(with-output-to-string
(s)
(assert (equal (apply fn s i (append (reverse x) rest)) rest)))))
("" "1" "12" "123" "1234" "12345"
"123456" "1234567" "12345678" "123456789" "12345678910"))
(def-format-test format.@{.11
"~@{X~:}" nil "X")
......@@ -259,6 +293,17 @@
("" "1" "12" "123" "1234" "12345" "123456" "1234567" "12345678"
"123456789" "12345678910"))
(deftest formatter.\:@.10
(let ((fn (formatter "~V@:{~A~}")))
(loop for i from 0 to 10
for x = nil then (cons (list i) x)
for rest = (list 'a 'b)
collect
(with-output-to-string
(s)
(assert (equal (apply fn s i (append (reverse x) rest)) rest)))))
("" "1" "12" "123" "1234" "12345" "123456" "1234567" "12345678"
"123456789" "12345678910"))
;;; Error tests
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment