Fixes GitHub issue #4. Needs cleanup.
This commit is contained in:
parent
220b23630c
commit
5488f1da5b
|
@ -5,6 +5,7 @@
|
||||||
[repltest-get-info get-info]))
|
[repltest-get-info get-info]))
|
||||||
|
|
||||||
(require (for-template repltest/private/run-interactions)
|
(require (for-template repltest/private/run-interactions)
|
||||||
|
(for-template repltest/private/modbg)
|
||||||
racket/syntax
|
racket/syntax
|
||||||
repltest/private/util
|
repltest/private/util
|
||||||
(only-in syntax/module-reader make-meta-reader)
|
(only-in syntax/module-reader make-meta-reader)
|
||||||
|
@ -13,7 +14,31 @@
|
||||||
(define ((wrap-reader reader) chr in src line col pos)
|
(define ((wrap-reader reader) chr in src line col pos)
|
||||||
(define/with-syntax (mod nm lang . body)
|
(define/with-syntax (mod nm lang . body)
|
||||||
(reader chr (narrow-until-prompt in) src line col pos))
|
(reader chr (narrow-until-prompt in) src line col pos))
|
||||||
#`(module nm racket
|
;(displayln "WARNING: skipping tests")(port->string in) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEBUG
|
||||||
|
|
||||||
|
(with-syntax ([(m1 n1 l1 (mb1 . bd1))
|
||||||
|
(eval #'(expand #`(mod nm lang . body))
|
||||||
|
(variable-reference->namespace (#%variable-reference)))])
|
||||||
|
#`(m1 n1 l1
|
||||||
|
(mb1 (module* test racket/base
|
||||||
|
(require repltest/private/run-interactions)
|
||||||
|
(run-interactions ;#'(mod nm lang . body)
|
||||||
|
(open-input-string #,(port->string in))
|
||||||
|
(#%variable-reference)))
|
||||||
|
. bd1)))
|
||||||
|
|
||||||
|
;#`(mod nm lang . body)
|
||||||
|
#;#`(mod nm repltest/private/modbg
|
||||||
|
require
|
||||||
|
(module nm lang (require lang) . body)
|
||||||
|
#;#,(port->string in)
|
||||||
|
(module* test racket/base
|
||||||
|
(require repltest/private/run-interactions)
|
||||||
|
(run-interactions ;#'(mod nm lang . body)
|
||||||
|
(open-input-string #,(port->string in))
|
||||||
|
(#%variable-reference)))))
|
||||||
|
#|
|
||||||
|
#;(insert-in-module
|
||||||
(module code lang . body)
|
(module code lang . body)
|
||||||
(require 'code)
|
(require 'code)
|
||||||
(provide (all-from-out 'code))
|
(provide (all-from-out 'code))
|
||||||
|
@ -21,7 +46,24 @@
|
||||||
(require repltest/private/run-interactions)
|
(require repltest/private/run-interactions)
|
||||||
(run-interactions #'(mod nm lang . body)
|
(run-interactions #'(mod nm lang . body)
|
||||||
(open-input-string #,(port->string in))
|
(open-input-string #,(port->string in))
|
||||||
(#%variable-reference)))))
|
(#%variable-reference))))
|
||||||
|
|
||||||
|
#;(define/with-syntax (mod2 nm2 lang2 (modbeg2 . body2))
|
||||||
|
(local-expand #'(module nm lang . body)
|
||||||
|
'module
|
||||||
|
'()))
|
||||||
|
#;((λ (x)
|
||||||
|
(displayln x)
|
||||||
|
x)
|
||||||
|
#`(mod2 nm2 lang2
|
||||||
|
(modbeg2
|
||||||
|
#;(module test racket/base
|
||||||
|
(require repltest/private/run-interactions)
|
||||||
|
(run-interactions #'(mod nm lang . body)
|
||||||
|
(open-input-string #,(port->string in))
|
||||||
|
(#%variable-reference)))
|
||||||
|
. body2)))
|
||||||
|
|#
|
||||||
|
|
||||||
(define-values (repltest-read repltest-read-syntax repltest-get-info)
|
(define-values (repltest-read repltest-read-syntax repltest-get-info)
|
||||||
(make-meta-reader
|
(make-meta-reader
|
||||||
|
|
54
private/modbg.rkt
Normal file
54
private/modbg.rkt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(provide (rename-out [insert-in-module #%module-begin]))
|
||||||
|
|
||||||
|
(require (for-syntax racket/base
|
||||||
|
syntax/strip-context))
|
||||||
|
|
||||||
|
(define-syntax (insert-in-module stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(_ rr
|
||||||
|
(mod1 nm1 lang1 (req lng) . bdy1);orig-mod
|
||||||
|
submod
|
||||||
|
;str
|
||||||
|
)
|
||||||
|
(with-syntax ([(mod nm lang (modbg . body)) (expand ;#'orig-mod
|
||||||
|
#'(mod1 nm1 lang1 . bdy1))])
|
||||||
|
;(with-syntax ([req (datum->syntax #'md1 'require)])
|
||||||
|
|
||||||
|
|
||||||
|
((λ (x)
|
||||||
|
(displayln x)
|
||||||
|
x)
|
||||||
|
(syntax-local-introduce
|
||||||
|
#`(modbg ;(require lang)
|
||||||
|
;(req #,(datum->syntax #'req (syntax->datum #'lang)))
|
||||||
|
;(rr lang)
|
||||||
|
. body)))
|
||||||
|
|
||||||
|
#;#`(modbg ;(require lang)
|
||||||
|
;; ok for #%top-interaction:
|
||||||
|
(req #,(datum->syntax #'req (syntax->datum #'lang)))
|
||||||
|
;; not ok for #%top-interaction:
|
||||||
|
;(req lang)
|
||||||
|
(rr lang)
|
||||||
|
(define varref (#,(datum->syntax #'lang '#%variable-reference)))
|
||||||
|
(provide varref)
|
||||||
|
submod
|
||||||
|
#;(module* test racket/base
|
||||||
|
(require repltest/private/run-interactions)
|
||||||
|
(require (submod ".."))
|
||||||
|
#;(define res-mod
|
||||||
|
(module-path-index-resolve
|
||||||
|
(module-path-index-join '(submod "..")
|
||||||
|
(variable-reference->module-path-index
|
||||||
|
varref))))
|
||||||
|
;(define mod-ns (module->namespace res-mod))
|
||||||
|
(define mod-ns (variable-reference->namespace varref))
|
||||||
|
(displayln mod-ns)
|
||||||
|
(run-interactions2 (open-input-string str)
|
||||||
|
mod-ns)
|
||||||
|
#;(run-interactions (open-input-string str)
|
||||||
|
#,(datum->syntax #'modbg '#%variable-reference)
|
||||||
|
#;(#%variable-reference)))
|
||||||
|
. body))]))
|
|
@ -1,22 +1,23 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(provide run-interactions)
|
(provide run-interactions
|
||||||
|
run-interactions2)
|
||||||
|
|
||||||
(require racket/syntax
|
(require racket/syntax
|
||||||
racket/port
|
racket/port
|
||||||
rackunit
|
rackunit
|
||||||
repltest/private/util)
|
repltest/private/util)
|
||||||
|
|
||||||
(define (run-interactions mod-stx in-rest varref)
|
(define (run-interactions in-rest varref)
|
||||||
(define/with-syntax (mod nm lang . body) mod-stx)
|
|
||||||
(let ([ns (make-base-namespace)])
|
|
||||||
;; This is a hack because I can't get (module->namespace ''nm) to work:
|
|
||||||
(define res-mod
|
(define res-mod
|
||||||
(module-path-index-resolve
|
(module-path-index-resolve
|
||||||
(module-path-index-join '(submod ".." code)
|
(module-path-index-join '(submod "..")
|
||||||
(variable-reference->module-path-index varref))))
|
(variable-reference->module-path-index varref))))
|
||||||
(dynamic-require res-mod #f)
|
(dynamic-require res-mod #f)
|
||||||
(define mod-ns (module->namespace res-mod))
|
(define mod-ns (module->namespace res-mod))
|
||||||
|
(run-interactions2 in-rest mod-ns))
|
||||||
|
|
||||||
|
(define (run-interactions2 in-rest mod-ns)
|
||||||
(let loop ()
|
(let loop ()
|
||||||
(let* ([pr (read-actual-prompt in-rest)])
|
(let* ([pr (read-actual-prompt in-rest)])
|
||||||
(when pr
|
(when pr
|
||||||
|
@ -40,4 +41,4 @@
|
||||||
[expected (port->string (narrow-until-prompt in-rest))])
|
[expected (port->string (narrow-until-prompt in-rest))])
|
||||||
(check-equal? actual
|
(check-equal? actual
|
||||||
expected))
|
expected))
|
||||||
(loop))))))
|
(loop)))))
|
|
@ -1,4 +1,5 @@
|
||||||
#lang debug repltest typed/racket
|
#lang debug repltest typed/racket
|
||||||
|
|
||||||
;; There is a problem if there is a comment before a prompt, as comments aren't
|
;; There is a problem if there is a comment before a prompt, as comments aren't
|
||||||
;; gobbled-up by the preceeding read.
|
;; gobbled-up by the preceeding read.
|
||||||
(define x 0)
|
(define x 0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#lang repltest racket
|
#lang repltest typed/racket
|
||||||
;; This file has the name "test", but it shouldn't cause any conflicts in module
|
;; This file has the name "test", but it shouldn't cause any conflicts in module
|
||||||
;; names
|
;; names
|
||||||
(define x 0)
|
(define x 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user