diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-04-19 12:33:25 -0400 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-01-22 23:04:05 +0100 |
| commit | c2dcff41c2e47f5f978f467864d5ed7829939884 (patch) | |
| tree | 2830b58567dd6a9a03fb40dfafef75eea491b1ef /tests | |
| parent | c498aaaf110cd7f6950ea47e637725e0513655d4 (diff) | |
records: Detect duplicate field initializers.
* guix/records.scm (report-duplicate-field-specifier): New procedure.
(make-syntactic-constructor): Call it.
* tests/records.scm ("define-record-type* & duplicate initializers"):
New test.
Co-authored-by: Mark H Weaver <mhw@netris.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/records.scm | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/records.scm b/tests/records.scm index 09ada70c2dc..d9469a78bd0 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 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019 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 | ;;; |
| @@ -288,6 +288,30 @@ | |||
| 288 | (and (string-match "extra.*initializer.*baz" message) | 288 | (and (string-match "extra.*initializer.*baz" message) |
| 289 | (eq? proc 'foo))))) | 289 | (eq? proc 'foo))))) |
| 290 | 290 | ||
| 291 | (test-assert "define-record-type* & duplicate initializers" | ||
| 292 | (let ((exp '(begin | ||
| 293 | (define-record-type* <foo> foo make-foo | ||
| 294 | foo? | ||
| 295 | (bar foo-bar (default 42))) | ||
| 296 | |||
| 297 | (foo (bar 1) | ||
| 298 | (bar 2)))) | ||
| 299 | (loc (current-source-location))) ;keep this alignment! | ||
| 300 | (catch 'syntax-error | ||
| 301 | (lambda () | ||
| 302 | (eval exp (test-module)) | ||
| 303 | #f) | ||
| 304 | (lambda (key proc message location form . args) | ||
| 305 | (and (string-match "duplicate.*initializer" message) | ||
| 306 | (eq? proc 'foo) | ||
| 307 | |||
| 308 | ;; Make sure the location is that of the field specifier. | ||
| 309 | (lset= equal? | ||
| 310 | (pk 'expected-loc | ||
| 311 | `((line . ,(- (assq-ref loc 'line) 1)) | ||
| 312 | ,@(alist-delete 'line loc))) | ||
| 313 | (pk 'actual-loc location))))))) | ||
| 314 | |||
| 291 | (test-assert "ABI checks" | 315 | (test-assert "ABI checks" |
| 292 | (let ((module (test-module))) | 316 | (let ((module (test-module))) |
| 293 | (eval '(begin | 317 | (eval '(begin |
