Merge wip-array refactor, up to cd43fdc5b7a7c
[bpt/guile.git] / test-suite / tests / compiler.test
1 ;;;; compiler.test --- tests for the compiler -*- scheme -*-
2 ;;;; Copyright (C) 2008, 2009 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 3 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 base compile))
22
23
24 \f
25 (with-test-prefix "basic"
26
27 (pass-if "compile to value"
28 (equal? (compile 1) 1)))
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 (begin
37 (compile '(define round round))
38 (compile '(eq? round (@@ (guile) round)))))
39
40 (pass-if "compile in current module"
41 (let ((o (begin
42 (compile '(define-macro (foo) 'bar))
43 (compile '(let ((bar 'ok)) (foo))))))
44 (and (module-ref (current-module) 'foo)
45 (eq? o 'ok))))
46
47 (pass-if "compile in fresh module"
48 (let* ((m (let ((m (make-module)))
49 (beautify-user-module! m)
50 m))
51 (o (begin
52 (compile '(define-macro (foo) 'bar) #:env m)
53 (compile '(let ((bar 'ok)) (foo)) #:env m))))
54 (and (module-ref m 'foo)
55 (eq? o 'ok)))))