diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 16:20:43 -0800 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-01-09 16:20:43 -0800 |
| commit | f06966df463bdba5912b999bcb6ab0badb83a561 (patch) | |
| tree | 325be54ab153da135db02498feafcea9cc3ea1aa /format.csc | |
| parent | Add some magic to detect symbols. (diff) | |
| download | chromatopelma-f06966df463bdba5912b999bcb6ab0badb83a561.tar.zst | |
Redo the testing framework.
We can lean more on the power of scheme to make the testing framework a
little less verbose.
Diffstat (limited to 'format.csc')
| -rw-r--r-- | format.csc | 33 |
1 files changed, 6 insertions, 27 deletions
@@ -1,10 +1,7 @@ (define-library (csc format) (export - vfprintf fprintf - vprintf printf - vsprintf sprintf) (import (scheme base) (only (scheme write) display) @@ -15,7 +12,7 @@ (begin - (define (vfprintf port format-string format-args) + (define (fprintf port format-string . format-args) (let loop ((start 0) (args format-args)) (cond ((>= start (string-length format-string))) @@ -42,29 +39,11 @@ (loop format-pos args)))))) - (define-syntax fprintf - (syntax-rules () - ((_ port format-string format-args ...) - (vfprintf port format-string (list format-args ...))))) + (define (printf format-string . format-args) + (apply fprintf (current-output-port) format-string format-args)) - (define (vprintf format-string format-args) - (vfprintf (current-output-port) format-string format-args)) - - - (define-syntax printf - (syntax-rules () - ((_ format-string format-args ...) - (vprintf format-string (list format-args ...))))) - - - (define (vsprintf format-string format-args) + (define (sprintf format-string . format-args) (let ((string-builder (open-output-string))) - (vfprintf string-builder format-string format-args) - (get-output-string string-builder))) - - - (define-syntax sprintf - (syntax-rules () - ((_ format-string format-args ...) - (vsprintf format-string (list format-args ...))))))) + (apply fprintf string-builder format-string format-args) + (get-output-string string-builder))))) |
