tests: Add sanitizer test.

* tests/records.scm ("define-record-type* & sanitize without default
value"): New test.
This commit is contained in:
Ludovic Courtès 2022-07-01 12:08:22 +02:00
parent 0dab106a6a
commit 741895676b
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012-2016, 2018-2022 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -300,6 +300,15 @@
(string=? (foo-bar r) "baz!") (string=? (foo-bar r) "baz!")
(equal? s r))))) (equal? s r)))))
(test-equal "define-record-type* & sanitize without default value"
42
(begin
(define-record-type* <foo> foo make-foo
foo?
(bar foo-bar (sanitize 1+)))
(foo-bar (foo (bar 41)))))
(test-assert "define-record-type* & sanitize & thunked" (test-assert "define-record-type* & sanitize & thunked"
(let ((sanitized 0)) (let ((sanitized 0))
(define-record-type* <foo> foo make-foo (define-record-type* <foo> foo make-foo
@ -321,6 +330,7 @@
(let ((r (foo (inherit q)))) (let ((r (foo (inherit q))))
(and (string=? (foo-bar r) "baz!") (and (string=? (foo-bar r) "baz!")
(= sanitized 2))))))))) ;no re-sanitization (= sanitized 2))))))))) ;no re-sanitization
(test-assert "define-record-type* & wrong field specifier" (test-assert "define-record-type* & wrong field specifier"
(let ((exp '(begin (let ((exp '(begin
(define-record-type* <foo> foo make-foo (define-record-type* <foo> foo make-foo