我的ocaml设置如下:
内联测试的源代码:
let rec foo x0 f = function
[] -> 0
| x::xs -> f x (foo x0 f xs);;
(*$T foo
foo 0 (+) [1;2] = 3
*)
qtest -o footest2.ml extract foo.ml
然后不幸的是,footest2.ml无法编译:
corebuild footest2.native -pkg quickcheck
let ___tests = ref []
let ___add test = ___tests := test::!___tests
open OUnit;;
module Q = Quickcheck;;let ( ==> ) = Q.( ==> );;
Random.self_init()
module Test__environment_0 = struct
open Foo;;
let _test_2 = "foo" >::: [
"foo.ml:6" >:: (
#6 "foo.ml"
let foo = foo in fun () -> OUnit.assert_bool "foo.ml:6: foo 0 (+) [1;2] = 3" (
#6 "foo.ml"
foo 0 (+) [1;2] = 3));
];; let _ = ___add _test_2;;
end
let _ = exit (Runner.run ("" >::: List.rev !___tests))
错误是:"错误:未绑定模块快速检查"
确实,它应该是QuickCheck而不是Quickcheck - 在修复此问题后,我收到了错误:错误:未绑定的值Q。==>。 删除后:
let(==>)= Q.(==>);;
以后编译失败: 错误:未绑定的模块运行器。
但是没有一个名为" Runner" ...
的模块有任何想法让这个工作吗?
答案 0 :(得分:1)
尝试使用QTest2Lib包而不是qtest或quickcheck:
corebuild footest2.native -pkg QTest2Lib