guile-rsv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 09bc8fa4ccae2c85b8df32e3c10187434e71a3d6
parent efeb9ec923bea071019961a2769e143d6ab587ed
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Mon,  8 Jan 2024 18:30:37 +0200

Add tests.

Diffstat:
Arsv/arbitrary-null-tests.scm | 30++++++++++++++++++++++++++++++
Mrsv/arbitrary-null.scm | 14+-------------
2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/rsv/arbitrary-null-tests.scm b/rsv/arbitrary-null-tests.scm @@ -0,0 +1,30 @@ +(define-library (rsv arbitrary-null-tests) + (import (scheme base) + (srfi srfi-64) + (rsv arbitrary-null)) + + (begin + (define (test null-value scm) + (let ((output-bytevector-port (open-output-bytevector))) + (scm->rsv scm + (lambda (x) + (equal? null-value + x)) + output-bytevector-port) + (let ((bytevector (get-output-bytevector output-bytevector-port))) + (let ((new-scm (rsv->scm null-value + (open-input-bytevector bytevector)))) + (test-equal + scm + new-scm))))) + + (test-begin "rsv-arbitrary-null-tests") + (test #f '()) + (test #f '((#f))) + (test #f '((""))) + (test #f '(("a"))) + (test #f '(("a" ""))) + (test #f '(("" "a"))) + (test #t '(("bc" "a") ("def" #t "efsdf") () ("def"))) + (test 10 '(("bc" "a") ("def" 10 "efsdf") () ("def"))) + (test-end "rsv-arbitrary-null-tests"))) diff --git a/rsv/arbitrary-null.scm b/rsv/arbitrary-null.scm @@ -88,16 +88,4 @@ (_ (loop (cons (row->scm null-value port) - rows)))))) - - (define (main args) - (let ((our-scm '(("abc" "" "") ("def" #f "ghi") () (#f)))) - (write our-scm) (newline) - (call-with-output-file "poop.rsv" - (lambda (port) - (scm->rsv our-scm - (lambda (x) (equal? #f x)) - port))) - (call-with-input-file "poop.rsv" - (lambda (port) - (write (rsv->scm #f port)) (newline))))))) + rows))))))))