(let ((accessor (record-accessor module-type 'name)))
(lambda (mod)
(or (accessor mod)
- (begin
- (set-module-name! mod (list (gensym)))
+ (let ((name (list (gensym))))
+ ;; Name MOD and bind it in THE-ROOT-MODULE so that it's visible
+ ;; to `resolve-module'. This is important as `psyntax' stores
+ ;; module names and relies on being able to `resolve-module'
+ ;; them.
+ (set-module-name! mod name)
+ (nested-define! the-root-module `(%app modules ,@name) mod)
(accessor mod))))))
;; (define-special-value '(%app modules new-ws) (lambda () (make-scm-module)))
;;;; compiler.test --- tests for the compiler -*- scheme -*-
-;;;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2001, 2006 Free Software Foundation, Inc.
+;;;; Copyright (C) 2008, 2009 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
:use-module (test-suite lib)
:use-module (test-suite guile-test)
:use-module (system base compile))
-
+
+\f
(with-test-prefix "basic"
(pass-if "compile to value"
;; imported `round'. See the same test in `syntax.test' for details.
(let ((o1 (compile '(define round round)))
(o2 (compile '(eq? round (@@ (guile) round)))))
- o2)))
+ o2))
+
+ (pass-if "compile in current module"
+ (let ((o1 (compile '(define-macro (foo) 'bar)))
+ (o2 (compile '(let ((bar 'ok)) (foo)))))
+ (and (module-ref (current-module) 'foo)
+ (eq? o2 'ok))))
+
+ (pass-if "compile in fresh module"
+ (let* ((m (let ((m (make-module)))
+ (beautify-user-module! m)
+ m))
+ (o1 (compile '(define-macro (foo) 'bar) #:env m))
+ (o2 (compile '(let ((bar 'ok)) (foo)) #:env m)))
+ (and (module-ref m 'foo)
+ (eq? o2 'ok)))))
;;;; modules.test --- exercise some of guile's module stuff -*- scheme -*-
-;;;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+;;;; Copyright (C) 2006, 2007, 2009 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
(with-test-prefix "foundations"
+ (pass-if "modules don't remain anonymous"
+ ;; This is a requirement for `psyntax': it stores module names and relies
+ ;; on being able to `resolve-module' them.
+ (let ((m (make-module)))
+ (and (module-name m)
+ (eq? m (resolve-module (module-name m))))))
+
(pass-if "module-add!"
(let ((m (make-module))
(value (cons 'x 'y)))