aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author(unmatched-parenthesis d <paren@disroot.org>2023-04-28 20:19:03 +0100
committerJosselin Poiret <dev@jpoiret.xyz>2023-06-04 10:34:35 +0200
commitb88e38d4b51b9aa0e857baeb614c000e491ad309 (patch)
tree91980dbd49110d9b313ab9bc66d9a23ace67514a /tests
parent1a4aace3af85bdfd5f513a4c5bb6925d1d0f50be (diff)
downloadguix-b88e38d4b51b9aa0e857baeb614c000e491ad309.tar
guix-b88e38d4b51b9aa0e857baeb614c000e491ad309.tar.gz
records: match-record: Support thunked and delayed fields.
* guix/records.scm (match-record): Unwrap matched thunked and delayed fields. * tests/records.scm ("match-record, thunked field", "match-record, delayed field"): New tests. Signed-off-by: Josselin Poiret <dev@jpoiret.xyz>
Diffstat (limited to 'tests')
-rw-r--r--tests/records.scm29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/records.scm b/tests/records.scm
index b1203dfeb7..4f0aeb3903 100644
--- a/tests/records.scm
+++ b/tests/records.scm
@@ -561,4 +561,33 @@ Description: 1st line,
(make-fresh-user-module)))
(lambda (key . args) key)))
+(test-equal "match-record, delayed field"
+ "foo bar bar foo"
+ (begin
+ (define-record-type* <with-delayed> with-delayed make-with-delayed
+ with-delayed?
+ (delayed with-delayed-delayed
+ (delayed)))
+
+ (let ((rec (with-delayed
+ (delayed "foo bar bar foo"))))
+ (match-record rec <with-delayed> (delayed)
+ delayed))))
+
+(test-equal "match-record, thunked field"
+ '("foo" "foobar")
+ (begin
+ (define-record-type* <with-thunked> with-thunked make-with-thunked
+ with-thunked?
+ (normal with-thunked-normal)
+ (thunked with-thunked-thunked
+ (thunked)))
+
+ (let ((rec (with-thunked
+ (normal "foo")
+ (thunked (string-append (with-thunked-normal this-record)
+ "bar")))))
+ (match-record rec <with-thunked> (normal thunked)
+ (list normal thunked)))))
+
(test-end)