Commit | Line | Data |
---|---|---|
3de80ed5 AW |
1 | ;;;; compiler.test --- tests for the compiler -*- scheme -*- |
2 | ;;;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2001, 2006 Free Software Foundation, Inc. | |
3 | ;;;; | |
4 | ;;;; This library is free software; you can redistribute it and/or | |
5 | ;;;; modify it under the terms of the GNU Lesser General Public | |
6 | ;;;; License as published by the Free Software Foundation; either | |
7 | ;;;; version 2.1 of the License, or (at your option) any later version. | |
8 | ;;;; | |
9 | ;;;; This library is distributed in the hope that it will be useful, | |
10 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | ;;;; Lesser General Public License for more details. | |
13 | ;;;; | |
14 | ;;;; You should have received a copy of the GNU Lesser General Public | |
15 | ;;;; License along with this library; if not, write to the Free Software | |
16 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | ||
18 | (define-module (test-suite tests compiler) | |
19 | :use-module (test-suite lib) | |
20 | :use-module (test-suite guile-test) | |
21 | :use-module (system vm program)) | |
22 | ||
23 | ||
24 | (with-test-prefix "environments" | |
25 | ||
26 | (pass-if "compile-time-environment in evaluator" | |
27 | (eq? (primitive-eval '(compile-time-environment)) #f)) | |
28 | ||
29 | (pass-if "compile-time-environment in compiler" | |
30 | (equal? (compile '(compile-time-environment)) | |
31 | (cons (current-module) | |
32 | (cons '() '())))) | |
33 | ||
34 | (let ((env (compile | |
35 | '(let ((x 0)) (set! x 1) (compile-time-environment))))) | |
36 | (pass-if "compile-time-environment in compiler, heap-allocated var" | |
37 | (equal? env | |
38 | (cons (current-module) | |
39 | (cons '((x . 0)) '(1))))) | |
40 | ||
41 | ;; fixme: compiling with #t or module | |
42 | (pass-if "recompiling with environment" | |
b0b180d5 | 43 | (equal? ((compile '(lambda () x) #:env env)) |
3de80ed5 AW |
44 | 1)) |
45 | ||
46 | (pass-if "recompiling with environment/2" | |
b0b180d5 | 47 | (equal? ((compile '(lambda () (set! x (1+ x)) x) #:env env)) |
3de80ed5 AW |
48 | 2)) |
49 | ||
50 | (pass-if "recompiling with environment/3" | |
b0b180d5 | 51 | (equal? ((compile '(lambda () x) #:env env)) |
3de80ed5 AW |
52 | 2)) |
53 | ) | |
54 | ||
55 | (pass-if "compile environment is #f" | |
56 | (equal? ((compile '(lambda () 10))) | |
57 | 10)) | |
58 | ||
59 | (pass-if "compile environment is a module" | |
b0b180d5 | 60 | (equal? ((compile '(lambda () 10) #:env (current-module))) |
3de80ed5 AW |
61 | 10)) |
62 | ) |