/[gcl]/gcl/ansi-tests/printer-aux.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/printer-aux.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by pfdietz, Wed Sep 29 03:16:31 2004 UTC revision 1.31 by pfdietz, Sat Nov 27 19:36:18 2004 UTC
# Line 400  Line 400 
400                               (* suffix-integer (expt 1/10 suffix-len)))))                               (* suffix-integer (expt 1/10 suffix-len)))))
401            (if neg (- magnitude) magnitude))))))            (if neg (- magnitude) magnitude))))))
402    
403    
404    ;;; Macro to define both FORMAT and FORMATTER tests
405    
406    (defmacro def-format-test (name string args expected-output)
407      (assert (symbolp name))
408      (let* ((s (symbol-name name))
409             (expected-prefix (string 'format.))
410             (expected-prefix-length (length expected-prefix)))
411        (assert (>= (length s) expected-prefix-length))
412        (assert (string-equal (subseq s 0 expected-prefix-length)
413                              expected-prefix))
414        (let* ((formatter-test-name-string
415                (concatenate 'string (string 'formatter.)
416                             (subseq s expected-prefix-length)))
417               (formatter-test-name (intern formatter-test-name-string
418                                            (symbol-package name)))
419               (formatter-form (if (stringp string)
420                                   `(formatter ,string)
421                                 (list 'formatter (eval string)))))
422          `(progn
423             (deftest ,name
424               (with-standard-io-syntax
425                (let ((*print-readably* nil))
426                  (format nil ,string ,@args)))
427               ,expected-output)
428             (deftest ,formatter-test-name
429               (let ((fn ,formatter-form)
430                     (args (list ,@args)))
431                 (with-standard-io-syntax
432                  (let ((*print-readably* nil))
433                    (with-output-to-string
434                      (stream)
435                      (apply fn stream args)
436                      ;; FIXME -- Need to check for tail return
437                      ;; The plan is to add an extra optional argument
438                      ;; to def-format-test that, when present, gives the
439                      ;; number of arguments that should be left over.
440                      ;; The FORMAT test will ignore this, but the FORMATTER
441                      ;; test will check that a list of that many values is
442                      ;; returned, and that they are the last values in ARGS.
443                      ))))
444               ,expected-output)))))

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26