aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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 /lib
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.
Diffstat (limited to 'lib')
-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
4 files changed, 69 insertions, 8 deletions
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