shiroさんにいただいたプログラムに少し手を加えてみた。gauche.testでテストを行いたかったので、一度jailモジュールの外で(use gauche.test)して、define-in-moduleで必要な関数をjailの中に定義している。

(define-module jail (extend scheme))

(define (prohibited . _)
  (error "prohibited operation"))

(define-in-module jail daol load)

(use gauche.test)
(define-in-module jail test-start test-start)
(define-in-module jail test-section test-section)
(define-in-module jail test test)
(define-in-module jail test-end test-end)
(define-in-module jail test* test*)

(define-in-module jail open-input-file prohibited)
(define-in-module jail open-output-file prohibited)
(define-in-module jail with-input-from-file prohibited)
(define-in-module jail with-output-from-file prohibited)
(define-in-module jail call-with-input-file prohibited)
(define-in-module jail call-with-output-file prohibited)
(define-in-module jail load prohibited)

(define *the-jail* (find-module 'jail))

(define-in-module jail interaction-environment (lambda () *the-jail*))
(define-in-module jail scheme-report-environment prohibited)
(define-in-module jail null-environment prohibited)

(select-module jail)

(doal "report1.scm")
;(define (f x) ....)

(test-start "hello world")

(test-section "my section")
(test* "(f 1)" (f 1) (f 1))

(test-end)

gauche.testでテストできるようになったことに満足。本当はloadも禁止したいが、loadを禁止してしまうとレポートとして提出してもらったプログラムも良めなくなるので、しかたなくdaolに名前を変えて残してある。なんとかならないかと思うけど、、、

※追記

loadは

(define-in-module jail (load x) (load "report1.scm"))

でいい気がしてきた。