403 |
|
|
404 |
;;; Macro to define both FORMAT and FORMATTER tests |
;;; Macro to define both FORMAT and FORMATTER tests |
405 |
|
|
406 |
(defmacro def-format-test (name string args expected-output) |
(defmacro def-format-test (name string args expected-output &optional (num-left 0)) |
407 |
(assert (symbolp name)) |
(assert (symbolp name)) |
408 |
(let* ((s (symbol-name name)) |
(let* ((s (symbol-name name)) |
409 |
(expected-prefix (string 'format.)) |
(expected-prefix (string 'format.)) |
422 |
`(progn |
`(progn |
423 |
(deftest ,name |
(deftest ,name |
424 |
(with-standard-io-syntax |
(with-standard-io-syntax |
425 |
(let ((*print-readably* nil)) |
(let ((*print-readably* nil) |
426 |
|
(*package* (symbol-package 'ABC))) |
427 |
(format nil ,string ,@args))) |
(format nil ,string ,@args))) |
428 |
,expected-output) |
,expected-output) |
429 |
(deftest ,formatter-test-name |
(deftest ,formatter-test-name |
430 |
(let ((fn ,formatter-form) |
(let ((fn ,formatter-form) |
431 |
(args (list ,@args))) |
(args (list ,@args))) |
432 |
(with-standard-io-syntax |
(with-standard-io-syntax |
433 |
(let ((*print-readably* nil)) |
(let ((*print-readably* nil) |
434 |
|
(*package* (symbol-package 'ABC))) |
435 |
(with-output-to-string |
(with-output-to-string |
436 |
(stream) |
(stream) |
437 |
(apply fn stream args) |
(let ((tail (apply fn stream args))) |
438 |
;; FIXME -- Need to check for tail return |
;; FIXME -- Need to check that TAIL really is a tail of ARGS |
439 |
;; The plan is to add an extra optional argument |
(assert (= (length tail) ,num-left) (tail) "Tail is ~A, length should be ~A" |
440 |
;; to def-format-test that, when present, gives the |
tail ,num-left) |
441 |
;; number of arguments that should be left over. |
))))) |
|
;; The FORMAT test will ignore this, but the FORMATTER |
|
|
;; test will check that a list of that many values is |
|
|
;; returned, and that they are the last values in ARGS. |
|
|
)))) |
|
442 |
,expected-output))))) |
,expected-output))))) |