Allow fresh modules to be passed to `compile'.
[bpt/guile.git] / test-suite / tests / compiler.test
CommitLineData
3de80ed5 1;;;; compiler.test --- tests for the compiler -*- scheme -*-
16f451f3 2;;;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3de80ed5
AW
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
53befeb7 7;;;; version 3 of the License, or (at your option) any later version.
3de80ed5
AW
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)
68623e8e 21 :use-module (system base compile))
3de80ed5 22
16f451f3
LC
23
24\f
68623e8e 25(with-test-prefix "basic"
3de80ed5 26
68623e8e
AW
27 (pass-if "compile to value"
28 (equal? (compile 1) 1)))
b9434165
LC
29
30\f
31(with-test-prefix "psyntax"
32
33 (pass-if "redefinition"
34 ;; In this case the locally-bound `round' must have the same value as the
35 ;; imported `round'. See the same test in `syntax.test' for details.
36 (let ((o1 (compile '(define round round)))
37 (o2 (compile '(eq? round (@@ (guile) round)))))
16f451f3
LC
38 o2))
39
40 (pass-if "compile in current module"
41 (let ((o1 (compile '(define-macro (foo) 'bar)))
42 (o2 (compile '(let ((bar 'ok)) (foo)))))
43 (and (module-ref (current-module) 'foo)
44 (eq? o2 'ok))))
45
46 (pass-if "compile in fresh module"
47 (let* ((m (let ((m (make-module)))
48 (beautify-user-module! m)
49 m))
50 (o1 (compile '(define-macro (foo) 'bar) #:env m))
51 (o2 (compile '(let ((bar 'ok)) (foo)) #:env m)))
52 (and (module-ref m 'foo)
53 (eq? o2 'ok)))))