运行其他模块的子模块

时间:2015-09-20 23:03:44

标签: module racket

我想从另一个模块中选择性地运行一个Racket模块的子模块。请帮我填空!

文件1

#lang racket/base

;; <big file, lots of code>

(module+ small-tests
   ;; basic correctness checks
   (displayln "Small tests pass!")
)

(module+ big-tests
   ;; heavy duty stress tests
   (displayln "Big tests pass!")
)

文件2

#lang racket/base

(module+ main
  ;; Trigger either the small-tests or the big-tests,
  ;; depending on what's written here.
  (require '???)
)

如果运行大型测试也会自动运行小型测试也会很棒。

1 个答案:

答案 0 :(得分:2)

submod表格用于要求模块的子模块。

举个例子:

#lang racket

(module A racket
  (module+ main
    (displayln "Hello World")))

(module B racket
  (require (submod ".." A main)))

(require 'B)