program与checked-example的源码写法[#34]
(lp checked)提供文章内的执行与核验。定义型program放在文章顶层,不能借助subtree参数自动成为顶层定义:
@use-modules[(flora commands) (lp checked) (language scribble commands)]
@program["short-square" "平方函数 square 的定义"]{
@(define (square x)
(* x x))
}
@checked-example["square-test" "square(4) 的结果" (square 4) 16]program执行定义并生成代码tree;checked-example求值表达式,将实际值与给定的预期做equal?比较。Program和Example是内容分类,不是运行按钮。完整标记说明见LP核验与依赖标记。