aboutsummaryrefslogtreecommitdiffstats
path: root/format.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-09 16:20:43 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-09 16:20:43 -0800
commitf06966df463bdba5912b999bcb6ab0badb83a561 (patch)
tree325be54ab153da135db02498feafcea9cc3ea1aa /format.csc
parentAdd some magic to detect symbols. (diff)
downloadchromatopelma-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.csc33
1 files changed, 6 insertions, 27 deletions
diff --git a/format.csc b/format.csc
index 2c2da84..48909a6 100644
--- a/format.csc
+++ b/format.csc
@@ -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)))))