From f06966df463bdba5912b999bcb6ab0badb83a561 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 9 Jan 2022 16:20:43 -0800 Subject: Redo the testing framework. We can lean more on the power of scheme to make the testing framework a little less verbose. --- format.csc | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'format.csc') 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))))) -- cgit v1.3.1