interp.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. (pass-if "Internal defines 1"
  19. (letrec ((foo (lambda (arg)
  20. (or arg (and (procedure? foo)
  21. (foo 99))))))
  22. (define bar (foo #f))
  23. (= (foo #f) 99)))
  24. (pass-if "Internal defines 2"
  25. (letrec ((foo 77)
  26. (bar #f)
  27. (retfoo (lambda () foo)))
  28. (define baz (retfoo))
  29. (= (retfoo) 77)))
  30. ;; Test that evaluation of closure bodies works as it should
  31. (with-test-prefix "closure bodies"
  32. (with-test-prefix "eval"
  33. (pass-if "expansion"
  34. ;; we really want exactly #f back from the closure
  35. (not ((lambda () (define ret #f) ret))))
  36. (pass-if "iloc escape"
  37. (not (let* ((x #f)
  38. (foo (lambda () x)))
  39. (foo) ; causes memoization of x
  40. (foo)))))
  41. (with-test-prefix "apply"
  42. (pass-if "expansion"
  43. (not (catch #t (lambda () (define ret #f) ret) (lambda a #t))))
  44. (pass-if "iloc escape"
  45. (not (let* ((x #f)
  46. (foo (lambda () x)))
  47. (foo)
  48. (catch #t foo (lambda a #t)))))))