| 1 |
;;;; interp.test --- tests for bugs in the Guile interpreter -*- scheme -*- |
| 2 |
;;;; |
| 3 |
;;;; Copyright (C) 1999, 2001, 2006 Free Software Foundation, Inc. |
| 4 |
;;;; |
| 5 |
;;;; This library is free software; you can redistribute it and/or |
| 6 |
;;;; modify it under the terms of the GNU Lesser General Public |
| 7 |
;;;; License as published by the Free Software Foundation; either |
| 8 |
;;;; version 3 of the License, or (at your option) any later version. |
| 9 |
;;;; |
| 10 |
;;;; This library is distributed in the hope that it will be useful, |
| 11 |
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
;;;; Lesser General Public License for more details. |
| 14 |
;;;; |
| 15 |
;;;; You should have received a copy of the GNU Lesser General Public |
| 16 |
;;;; License along with this library; if not, write to the Free Software |
| 17 |
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
|
| 19 |
(define-module (test-suite test-interp) |
| 20 |
#:use-module (test-suite lib)) |
| 21 |
|
| 22 |
(pass-if "Internal defines 1" |
| 23 |
(letrec ((foo (lambda (arg) |
| 24 |
(or arg (and (procedure? foo) |
| 25 |
(foo 99)))))) |
| 26 |
(define bar (foo #f)) |
| 27 |
(= (foo #f) 99))) |
| 28 |
|
| 29 |
(pass-if "Internal defines 2" |
| 30 |
(letrec ((foo 77) |
| 31 |
(bar #f) |
| 32 |
(retfoo (lambda () foo))) |
| 33 |
(define baz (retfoo)) |
| 34 |
(= (retfoo) 77))) |
| 35 |
|
| 36 |
;; Test that evaluation of closure bodies works as it should |
| 37 |
|
| 38 |
(with-test-prefix "closure bodies" |
| 39 |
(with-test-prefix "eval" |
| 40 |
(pass-if "expansion" |
| 41 |
;; we really want exactly #f back from the closure |
| 42 |
(not ((lambda () (define ret #f) ret)))) |
| 43 |
(pass-if "iloc escape" |
| 44 |
(not (let* ((x #f) |
| 45 |
(foo (lambda () x))) |
| 46 |
(foo) ; causes memoization of x |
| 47 |
(foo))))) |
| 48 |
(with-test-prefix "apply" |
| 49 |
(pass-if "expansion" |
| 50 |
(not (catch #t (lambda () (define ret #f) ret) (lambda a #t)))) |
| 51 |
(pass-if "iloc escape" |
| 52 |
(not (let* ((x #f) |
| 53 |
(foo (lambda () x))) |
| 54 |
(foo) |
| 55 |
(catch #t foo (lambda a #t))))))) |