aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-08-05 18:20:28 -0400
committerGravatar Peter McGoron 2025-08-05 18:20:28 -0400
commitf36f61cb4ab68285b2ba4a230f312843e4faf885 (patch)
tree32fd2958c18c54c875171bf177217b2d44dd06cf
parentadd adjustable value rewriter (diff)
Support Foment
Foment had some peculiarities: 1. Parameterize objects are initialized with the objects themselves at some point, which broke the previous code. 2. Foment cannot discard multiple value returns in some scenarios.
-rw-r--r--.gitignore1
-rw-r--r--README.md14
-rw-r--r--lib/conspire.scm10
-rw-r--r--lib/conspire.sld3
-rw-r--r--lib/rewriters.foment.scm45
-rw-r--r--lib/rewriters.r7rs.scm19
-rwxr-xr-xtests/foment.sh3
-rw-r--r--tests/impl.scm45
-rw-r--r--tests/run.scm2
9 files changed, 109 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index 111df7d..bccdb7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-tests/*.log
*.import.scm
*.a
*.o
diff --git a/README.md b/README.md
index 9d00465..8067893 100644
--- a/README.md
+++ b/README.md
@@ -185,3 +185,17 @@ Multi-threaded implementations must export an SRFI-18 compatible
interface for mutexes. Single threaded implementations can use the
`compat.single-threaded.sld` (`compat.single-threaded.sls` for R6RS)
implementations.
+
+## Instructions Per Implementation
+
+### CHICKEN
+
+Just run `chicken-install conspire`.
+
+### Foment
+
+You will need `srfi-225`. The [reference implementation][SRFI-225] will
+work out of the box. Test bodies cannot return multiple values.
+
+[SRFI-225]: https://github.com/scheme-requests-for-implementation/srfi-225
+
diff --git a/lib/conspire.scm b/lib/conspire.scm
index 549bf11..74a4c03 100644
--- a/lib/conspire.scm
+++ b/lib/conspire.scm
@@ -178,7 +178,7 @@
key)
(display (test-rewrite key))
(display ": ")
- (display (test-rewrite value))
+ (write (test-rewrite value))
(newline)))
previous-dict)))
@@ -198,10 +198,10 @@
(cond
(success?
(when (or verbose? specifically-verbose?)
- (display (string-append "PASS: \"" name "\"\n"))
- (display-report previous-dto previous-test-info)))
+ (display (string-append "PASS: \"" name "\"\n"))))
(else
- (display (string-append "FAIL: \"" name "\"\n"))))
+ (display (string-append "FAIL: \"" name "\"\n"))
+ (display-report previous-dto previous-test-info)))
(values previous-dto previous-test-info)))
(define (default-on-exception exn return)
@@ -290,6 +290,8 @@
(list 'replace default-test-info-dto default-test-info-dict)
(lambda (value)
(cond
+ ;; TODO: Should putting in a new test info be allowed?
+ ((test-info? value) value)
((not (pair? value))
(raise-conspire-error "invalid arguments to parameterize"
value))
diff --git a/lib/conspire.sld b/lib/conspire.sld
index 73281b2..7f8e0ed 100644
--- a/lib/conspire.sld
+++ b/lib/conspire.sld
@@ -59,6 +59,9 @@
(chicken (import (srfi 18))
(include "r7rs-srfi-18.scm")
(include-library-declarations "rewriters.chicken.scm"))
+ (foment (import (srfi 18))
+ (include "r7rs-srfi-18.scm")
+ (include-library-declarations "rewriters.foment.scm"))
(else (include "r7rs-single-threaded.scm")
(include-library-declarations "rewriters.r7rs.scm")))
(include "conspire.scm")) \ No newline at end of file
diff --git a/lib/rewriters.foment.scm b/lib/rewriters.foment.scm
new file mode 100644
index 0000000..4d26429
--- /dev/null
+++ b/lib/rewriters.foment.scm
@@ -0,0 +1,45 @@
+#| Copyright © 2025 Peter McGoron
+ |
+ | Permission is hereby granted, free of charge, to any person obtaining
+ | a copy of this software and associated documentation files (the
+ | “Software”), to deal in the Software without restriction, including
+ | without limitation the rights to use, copy, modify, merge, publish,
+ | distribute, sublicense, and/or sell copies of the Software, and to
+ | permit persons to whom the Software is furnished to do so, subject to
+ | the following conditions:
+ |
+ | The above copyright notice and this permission notice shall be included
+ | in all copies or substantial portions of the Software.
+ |
+ | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+ | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ | THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ |#
+
+(import (only (foment base)
+ error-object-type
+ error-object-who
+ error-object-kind))
+
+(begin
+ (define (default-on-pair pair)
+ (cons (test-rewrite (car pair))
+ (test-rewrite (cdr pair))))
+ (define (default-on-vector vec)
+ (vector-map test-rewrite vec))
+ (define (default-on-error error)
+ (let ((msg (error-object-message error))
+ (irritants (error-object-irritants error)))
+ `(error (type ,(test-rewrite (error-object-type error)))
+ (who ,(test-rewrite (error-object-who error)))
+ (kind ,(test-rewrite (error-object-kind error)))
+ (msg ,(test-rewrite (error-object-message error)))
+ (irritants ,@(map test-rewrite (error-object-irritants error))))))
+ (define default-rewriters
+ `((,pair? . ,default-on-pair)
+ (,vector? . ,default-on-vector)
+ (,error-object? . ,default-on-error)))) \ No newline at end of file
diff --git a/lib/rewriters.r7rs.scm b/lib/rewriters.r7rs.scm
index 8c3db78..3b6ba96 100644
--- a/lib/rewriters.r7rs.scm
+++ b/lib/rewriters.r7rs.scm
@@ -20,7 +20,18 @@
| THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|#
-(begin (define default-rewriters
- `((,pair? . ,default-on-pair)
- (,vector? . ,default-on-vector)
- (,error-object? ,default-on-error)))) \ No newline at end of file
+(begin
+ (define (default-on-pair pair)
+ (cons (test-rewrite (car pair))
+ (test-rewrite (cdr pair))))
+ (define (default-on-vector vec)
+ (vector-map test-rewrite vec))
+ (define (default-on-error error)
+ (let ((msg (error-object-message error))
+ (irritants (error-object-irritants error)))
+ (display (list msg irritants)) (newline)
+ (cons 'error (cons msg irritants))))
+ (define default-rewriters
+ `((,pair? . ,default-on-pair)
+ (,vector? . ,default-on-vector)
+ (,error-object? . ,default-on-error)))) \ No newline at end of file
diff --git a/tests/foment.sh b/tests/foment.sh
new file mode 100755
index 0000000..5dd4c04
--- /dev/null
+++ b/tests/foment.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+foment -A "../lib" -A "../compat/srfi-225" -l run.scm
diff --git a/tests/impl.scm b/tests/impl.scm
index bae066a..a25fa10 100644
--- a/tests/impl.scm
+++ b/tests/impl.scm
@@ -98,39 +98,39 @@
'before-test! dummy
'setup-test! dummy
'when-test-skipped dummy
- 'after-test dummy
+ 'after-test values
'report-test dummy
'on-exception dummy
'setup-group! dummy
'before-group! dummy
- 'after-group dummy
+ 'after-group values
'report-group dummy)))))
(test-group "call-as-test, dummy dict"
(test-group "before test"
- (with-test-assert "before-test skips tests when returning #f"
+ (with-test-assert "skip-test? skips tests when returning #f"
(parameterize ((test-info
(list 'replace
(dict-set! dummy-dto dummy-dict
- 'before-test!
- (lambda (name) #f)))))
+ 'skip-test?
+ (lambda (name) #t)))))
(let ((called? #f))
(call-as-test "name" (lambda () (set! called? #t)))
- (not called?)))
- (with-test-assert "before-test gets the test name"
- (define inside-test-info
- (dict-set! dummy-dto dummy-dict
- 'before-test!
- (lambda (name)
- (unless (equal? name "1234")
- (raise "exception"))
- #t)))
- (parameterize ((test-info
+ (not called?))))
+ (with-test-assert "before-test gets the test name"
+ (define inside-test-info
+ (dict-set! dummy-dto dummy-dict
+ 'before-test!
+ (lambda (name)
+ (unless (equal? name "1234")
+ (raise "exception"))
+ #t)))
+ (parameterize ((test-info
(list 'replace inside-test-info)))
- (let ((called? #f))
- (call-as-test "1234"
- (lambda () (set! called? #t)))
- called?)))))
+ (let ((called? #f))
+ (call-as-test "1234"
+ (lambda () (set! called? #t)))
+ called?))))
(test-group "after test"
(let ((called? #f)
(pair (cons #f #f)))
@@ -289,7 +289,7 @@
(test-eqv "test number" 1 (dict-ref outer-dto outer-dict 'tests))))
(test-group "call-as-group"
- (with-test-assert "group with no tests"
+ (test-group "group with no tests"
(define-values (dto dict)
(parameterize ((test-info (list 'replace default-test-info-dto silent-dict)))
(call-as-group #f (lambda () #f))
@@ -298,7 +298,7 @@
(test-eqv "tests number" 0 (dict-ref dto dict 'tests))
(test-eqv "failed number" 0 (dict-ref dto dict 'failed))
(test-eqv "skipped number" 0 (dict-ref dto dict 'skipped)))
- (with-test-assert "group with 1 test"
+ (test-group "group with 1 test"
(define-values (dto dict)
(parameterize ((test-info (list 'replace default-test-info-dto silent-dict)))
(test-group #f (with-test-assert #f #t))
@@ -321,13 +321,12 @@
(call-as-test #f (lambda ()
(test-set! 'success? #f)))))
(inspect-test-info values)))
- ;; TODO: fix failing
(begin
(test-eqv "passed number" 2 (dict-ref dto dict 'passed))
(test-eqv "tests number" 4 (dict-ref dto dict 'tests))
(test-eqv "failed number" 1 (dict-ref dto dict 'failed))
(test-eqv "skipped number" 1 (dict-ref dto dict 'skipped))))
- (with-test-assert "nested groups"
+ (test-group "nested groups"
(define inner-dict #f)
(define inner-dto #f)
(define-values (dto dict)
diff --git a/tests/run.scm b/tests/run.scm
index 569ef2e..2eb43ad 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -22,7 +22,7 @@
(cond-expand
(chicken-5 (import r7rs))
- (else))
+ (else #f))
(import (conspire) (srfi 225) (scheme load))
(include "impl.scm")