diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-07-01 12:08:22 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-07-01 12:10:29 +0200 |
| commit | 741895676b124a8a9a6656a54b5b58fd35d8e0f9 (patch) | |
| tree | 69cd635de4e74aba4462de4288d7e13c9accbf6b /tests | |
| parent | 0dab106a6af36eaebfd533d3e38c1275deb85935 (diff) | |
tests: Add sanitizer test.
* tests/records.scm ("define-record-type* & sanitize without default
value"): New test.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/records.scm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/records.scm b/tests/records.scm index d014e7a995a..00c58b07364 100644 --- a/tests/records.scm +++ b/tests/records.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2012-2016, 2018-2022 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -300,6 +300,15 @@ | |||
| 300 | (string=? (foo-bar r) "baz!") | 300 | (string=? (foo-bar r) "baz!") |
| 301 | (equal? s r))))) | 301 | (equal? s r))))) |
| 302 | 302 | ||
| 303 | (test-equal "define-record-type* & sanitize without default value" | ||
| 304 | 42 | ||
| 305 | (begin | ||
| 306 | (define-record-type* <foo> foo make-foo | ||
| 307 | foo? | ||
| 308 | (bar foo-bar (sanitize 1+))) | ||
| 309 | |||
| 310 | (foo-bar (foo (bar 41))))) | ||
| 311 | |||
| 303 | (test-assert "define-record-type* & sanitize & thunked" | 312 | (test-assert "define-record-type* & sanitize & thunked" |
| 304 | (let ((sanitized 0)) | 313 | (let ((sanitized 0)) |
| 305 | (define-record-type* <foo> foo make-foo | 314 | (define-record-type* <foo> foo make-foo |
| @@ -321,6 +330,7 @@ | |||
| 321 | (let ((r (foo (inherit q)))) | 330 | (let ((r (foo (inherit q)))) |
| 322 | (and (string=? (foo-bar r) "baz!") | 331 | (and (string=? (foo-bar r) "baz!") |
| 323 | (= sanitized 2))))))))) ;no re-sanitization | 332 | (= sanitized 2))))))))) ;no re-sanitization |
| 333 | |||
| 324 | (test-assert "define-record-type* & wrong field specifier" | 334 | (test-assert "define-record-type* & wrong field specifier" |
| 325 | (let ((exp '(begin | 335 | (let ((exp '(begin |
| 326 | (define-record-type* <foo> foo make-foo | 336 | (define-record-type* <foo> foo make-foo |
