aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-07-01 17:32:03 +0200
committerLudovic Courtès <ludo@gnu.org>2012-07-03 21:59:56 +0200
commit8fd5bd2b69b51e370144f26c01201a178c024483 (patch)
tree3889c1a00d30d2c5e51286c83536ee71c5a01149 /tests
parente4c245f8a5f6b6485f980b9c4274909ee8ef567a (diff)
downloadgnu-guix-8fd5bd2b69b51e370144f26c01201a178c024483.tar
gnu-guix-8fd5bd2b69b51e370144f26c01201a178c024483.tar.gz
define-record-type*: Add `letrec*' behavior.
* guix/utils.scm (define-record-type*)[make-syntactic-constructor]: Bind all the ((FIELD VALUE) ...) in a `letrec*'. Adjust `field-value' accordingly. * tests/utils.scm ("define-record-type* with letrec* behavior"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/utils.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index 83a78b7a78..4a24e23df9 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -112,6 +112,22 @@
(match (foo (bar 1))
(($ <foo> 1 42) #t)))))
+(test-assert "define-record-type* with letrec* behavior"
+ ;; Make sure field initializers can refer to each other as if they were in
+ ;; a `letrec*'.
+ (begin
+ (define-record-type* <bar> bar make-bar
+ foo?
+ (x bar-x)
+ (y bar-y (default (+ 40 2)))
+ (z bar-z))
+ (and (match (bar (x 1) (y (+ x 1)) (z (* y 2)))
+ (($ <bar> 1 2 4) #t))
+ (match (bar (x 7) (z (* x 3)))
+ (($ <bar> 7 42 21)))
+ (match (bar (z 21) (x (/ z 3)))
+ (($ <bar> 7 42 21))))))
+
(test-end)