summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2022-12-02 19:13:45 +0100
committerMarius Bakke <marius@gnu.org>2022-12-02 19:13:45 +0100
commitf2b6350a507158b2a0ed28ada69d8ca3f544d5e5 (patch)
tree0dc9a7d9702e912b2fa098942a75e3e925629157 /tests
parentc5e15ef4ddcbe7ebf77b4d24a99707396121cb6c (diff)
parent365b0b55334ab61e73f368f142af7aa1c3a3d28a (diff)
Merge branch 'master' into staging
Diffstat (limited to 'tests')
-rw-r--r--tests/records.scm33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/records.scm b/tests/records.scm
index 00c58b0736..8504c8d5a5 100644
--- a/tests/records.scm
+++ b/tests/records.scm
@@ -528,4 +528,37 @@ Description: 1st line,
'("a" "b" "c")
'("a")))
+(test-equal "match-record, simple"
+ '((1 2) (a b))
+ (let ()
+ (define-record-type* <foo> foo make-foo
+ foo?
+ (first foo-first (default 1))
+ (second foo-second))
+
+ (list (match-record (foo (second 2)) <foo>
+ (first second)
+ (list first second))
+ (match-record (foo (first 'a) (second 'b)) <foo>
+ (second first)
+ (list first second)))))
+
+(test-equal "match-record, unknown field"
+ 'syntax-error
+ (catch 'syntax-error
+ (lambda ()
+ (eval '(begin
+ (use-modules (guix records))
+
+ (define-record-type* <foo> foo make-foo
+ foo?
+ (first foo-first (default 1))
+ (second foo-second))
+
+ (match-record (foo (second 2)) <foo>
+ (one two)
+ #f))
+ (make-fresh-user-module)))
+ (lambda (key . args) key)))
+
(test-end)