mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
New file.
This commit is contained in:
parent
7c9da364a4
commit
42b4fcb48d
1 changed files with 133 additions and 0 deletions
133
test-suite/tests/srfi-11.test
Normal file
133
test-suite/tests/srfi-11.test
Normal file
|
@ -0,0 +1,133 @@
|
|||
;;;; srfi-11.test --- exercise SRFI-11 let-values
|
||||
;;;;
|
||||
;;;; Copyright 2004 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or modify
|
||||
;;;; it under the terms of the GNU General Public License as published by
|
||||
;;;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;;;; any later version.
|
||||
;;;;
|
||||
;;;; This program 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 General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU General Public License
|
||||
;;;; along with this software; see the file COPYING. If not, write to
|
||||
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
;;;; Boston, MA 02111-1307 USA
|
||||
|
||||
(define-module (test-suite test-srfi-11)
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module (srfi srfi-11))
|
||||
|
||||
|
||||
;;
|
||||
;; let-values
|
||||
;;
|
||||
|
||||
(with-test-prefix "let-values"
|
||||
|
||||
(with-test-prefix "no exprs"
|
||||
|
||||
(pass-if "no values"
|
||||
(let-values ()
|
||||
#t)))
|
||||
|
||||
(with-test-prefix "one expr"
|
||||
|
||||
(pass-if "no values"
|
||||
(let-values ((() (values)))
|
||||
#t))
|
||||
|
||||
(pass-if "one value"
|
||||
(let-values (((x) (values 1)))
|
||||
(equal? x 1)))
|
||||
|
||||
(pass-if "one value as rest"
|
||||
(let-values ((x (values 1)))
|
||||
(equal? x '(1))))
|
||||
|
||||
(pass-if "two values"
|
||||
(let-values (((x y) (values 1 2)))
|
||||
(and (equal? x 1)
|
||||
(equal? y 2)))))
|
||||
|
||||
(with-test-prefix "two exprs"
|
||||
|
||||
(pass-if "no values each"
|
||||
(let-values ((() (values))
|
||||
(() (values)))
|
||||
#t))
|
||||
|
||||
(pass-if "one value / no values"
|
||||
(let-values (((x) (values 1))
|
||||
(() (values)))
|
||||
(equal? x 1)))
|
||||
|
||||
(pass-if "one value each"
|
||||
(let-values (((x) (values 1))
|
||||
((y) (values 2)))
|
||||
(and (equal? x 1)
|
||||
(equal? y 2))))
|
||||
|
||||
(pass-if-exception "first binding invisible to second expr"
|
||||
'(unbound-variable . ".*")
|
||||
(let-values (((x) (values 1))
|
||||
((y) (values (1+ x))))
|
||||
#f))))
|
||||
|
||||
;;
|
||||
;; let*-values
|
||||
;;
|
||||
|
||||
(with-test-prefix "let*-values"
|
||||
|
||||
(with-test-prefix "no exprs"
|
||||
|
||||
(pass-if "no values"
|
||||
(let*-values ()
|
||||
#t)))
|
||||
|
||||
(with-test-prefix "one expr"
|
||||
|
||||
(pass-if "no values"
|
||||
(let*-values ((() (values)))
|
||||
#t))
|
||||
|
||||
(pass-if "one value"
|
||||
(let*-values (((x) (values 1)))
|
||||
(equal? x 1)))
|
||||
|
||||
(pass-if "one value as rest"
|
||||
(let-values ((x (values 1)))
|
||||
(equal? x '(1))))
|
||||
|
||||
(pass-if "two values"
|
||||
(let*-values (((x y) (values 1 2)))
|
||||
(and (equal? x 1)
|
||||
(equal? y 2)))))
|
||||
|
||||
(with-test-prefix "two exprs"
|
||||
|
||||
(pass-if "no values each"
|
||||
(let*-values ((() (values))
|
||||
(() (values)))
|
||||
#t))
|
||||
|
||||
(pass-if "one value / no values"
|
||||
(let*-values (((x) (values 1))
|
||||
(() (values)))
|
||||
(equal? x 1)))
|
||||
|
||||
(pass-if "one value each"
|
||||
(let*-values (((x) (values 1))
|
||||
((y) (values 2)))
|
||||
(and (equal? x 1)
|
||||
(equal? y 2))))
|
||||
|
||||
(pass-if "first binding visible to second expr"
|
||||
(let*-values (((x) (values 1))
|
||||
((y) (values (1+ x))))
|
||||
(and (equal? x 1)
|
||||
(equal? y 2))))))
|
Loading…
Add table
Add a link
Reference in a new issue