Search code examples
ocamlquickcheck

Using qtest and quickcheck, fail to compile the test code


My ocaml setting is the following :

  • ocaml 4.01.0
  • opam 1.1.2
  • qtest 2.0.1 (opam list qtest)
  • quickcheck 1.0.0

The source code with test inlined :

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

Then unfortunately, footest2.ml fails to compile:

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))

the error being: "Error: Unbound module Quickcheck"

Indeed, it should be QuickCheck instead of Quickcheck - after fixing this, I got the error : Error: Unbound value Q.==>. After removal of :

let ( ==> ) = Q.( ==> );;

The compilation fails later : Error: Unbound module Runner.

But no module called "Runner"...

Any idea to get this working?


Solution

  • Try using the package QTest2Lib instead of qtest or quickcheck:

    corebuild footest2.native -pkg QTest2Lib