diff options
Diffstat (limited to 'test-suite/tests')
-rw-r--r-- | test-suite/tests/compiler.test | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test-suite/tests/compiler.test b/test-suite/tests/compiler.test new file mode 100644 index 000000000..dc27d6dc1 --- /dev/null +++ b/test-suite/tests/compiler.test @@ -0,0 +1,62 @@ +;;;; compiler.test --- tests for the compiler -*- scheme -*- +;;;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2001, 2006 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 2.1 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 tests compiler) + :use-module (test-suite lib) + :use-module (test-suite guile-test) + :use-module (system vm program)) + + +(with-test-prefix "environments" + + (pass-if "compile-time-environment in evaluator" + (eq? (primitive-eval '(compile-time-environment)) #f)) + + (pass-if "compile-time-environment in compiler" + (equal? (compile '(compile-time-environment)) + (cons (current-module) + (cons '() '())))) + + (let ((env (compile + '(let ((x 0)) (set! x 1) (compile-time-environment))))) + (pass-if "compile-time-environment in compiler, heap-allocated var" + (equal? env + (cons (current-module) + (cons '((x . 0)) '(1))))) + + ;; fixme: compiling with #t or module + (pass-if "recompiling with environment" + (equal? ((compile '(lambda () x) env)) + 1)) + + (pass-if "recompiling with environment/2" + (equal? ((compile '(lambda () (set! x (1+ x)) x) env)) + 2)) + + (pass-if "recompiling with environment/3" + (equal? ((compile '(lambda () x) env)) + 2)) + ) + + (pass-if "compile environment is #f" + (equal? ((compile '(lambda () 10))) + 10)) + + (pass-if "compile environment is a module" + (equal? ((compile '(lambda () 10) (current-module))) + 10)) + )
\ No newline at end of file |