[racket-dev] modules with both 'test' and 'main' submodules: looks like a Dr bug?

From: John Clements (clements at brinckerhoff.org)
Date: Thu Apr 26 16:54:35 EDT 2012

I'm seeing an inconsistency in the behavior of submodules that looks like a bug in DrRacket (as opposed to Racket).

First, though, it looks like running a module in DrRacket runs *both* the main and test submodules, if they both exist. I don't think this behavior is documented; I see this text:

"When a module is provided as a program name to the racket executable or run directly within DrRacket, if the module has a main submodule, the main submodule is run after its enclosing module."

… but no similar mention of 'test'. So I'm guessing that's just a doc bug?

The bigger issue, though, arises when I have a file containing both 'test' and 'main' submodules. It appears to me that I can't require the 'main' module externally when the modules are stored in separate files, but that I can when e.g. using #lang racket/load.

So, this program:

#lang racket/load

(module foo racket
(define (g) (printf "abc\n"))
(define (h) (printf "def\n"))

(module+ test
  (g))

(module+ main
  (h))
)

(module bar racket
  (require (submod 'foo main)))

(require 'bar)

… produces output "def", as I'd expect, but splitting it into two files:

foo.rkt:

#lang racket

(define (g) (printf "abc\n"))
(define (h) (printf "def\n"))

(module+ test
  (g))

(module+ main
  (h))


bar.rkt:

#lang racket

(require (submod "foo.rkt" main))



… and running "bar.rkt"  *in DrRacket* produces this message:

require: unknown module: (submod "/private/tmp/foo.rkt" main)


Running it from the command line, though, does what I'd expect:

pcp069222pcs:/tmp clements$ racket ./bar.rkt
def



So it looks like DrRacket's not doing quite the right thing here.

Apologies if this has been fixed since  5.3.0.2--2012-04-20(873c1bc/g) [3m].

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120426/dda5fdde/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120426/dda5fdde/attachment.p7s>

Posted on the dev mailing list.