我想从另一个模块中选择性地运行一个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 '???)
)
如果运行大型测试也会自动运行小型测试也会很棒。
答案 0 :(得分:2)
submod
表格用于要求模块的子模块。
举个例子:
#lang racket
(module A racket
(module+ main
(displayln "Hello World")))
(module B racket
(require (submod ".." A main)))
(require 'B)