1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
guile/test-suite/tests/srfi-31.test
Ludovic Courtès e7350baf1e Rewrite SRFI-31 in terms of `syntax-rules'.
* module/srfi/srfi-31.scm: Use `#:export' instead of `#:export-syntax'.
  (rec): Rewrite using `syntax-rules'.

* test-suite/tests/srfi-31.test ("rec special form"): Change exception
  type to EXCEPTION:SYNTAX-PATTERN-UNMATCHED.
2012-09-11 23:39:32 +02:00

39 lines
1.5 KiB
Scheme

;;;; srfi-31.test --- Test suite for Guile's SRFI-31 functions. -*- scheme -*-
;;;;
;;;; Copyright (C) 2004, 2006, 2010, 2012 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-srfi-31)
#:use-module (test-suite lib)
#:use-module (srfi srfi-31))
(with-test-prefix "rec special form"
(pass-if-exception "bogus variable"
exception:syntax-pattern-unmatched
(eval '(rec #:foo) (current-module)))
(pass-if "rec expressions"
(let ((ones-list (rec ones (cons 1 (delay ones)))))
(and (= 1 (car ones-list))
(= 1 (car (force (cdr ones-list)))))))
(pass-if "rec functions"
(let ((test-func (rec (add-upto n)
(if (positive? n)
(+ n (add-upto (- n 1)))
0))))
(= 15 (test-func 5)))))