(* TO DO: * handle the following errors from IntexInterTest tooBigArg 5 = ***TESTING MISMATCH*** *** Expected: Illegal arg index: 2 *** Actual: Unbound variable: $2 zeroArg 6 = ***TESTING MISMATCH*** *** Expected: Illegal arg index: 0 *** Actual: Unbound variable: $0 negArg 7 = ***TESTING MISMATCH*** *** Expected: Illegal arg index: -1 *** Actual: Unbound variable: $-1 *) module type IBEX_INTERP = sig exception EvalError of string val run : Ibex.pgm -> int list -> int end module type IBEX_TEST = sig val test : unit -> unit end module IbexInterpTest (IbexInterp: IBEX_INTERP): IBEX_TEST = struct open IntexInterpTest module IbexTester = MakeTester ( struct type prog = string type arg = int type res = result let trial progString args = try Val(IbexInterp.run (Ibex.stringToPgm progString) args) with IbexInterp.EvalError(str) -> Err(str) | Sexp.IllFormedSexp(str) -> Err(str) (* Other exceptions will be passed through by default *) let argToString = string_of_int let resEqual = (=) let resToString = resultToString end ) let entries = [ ("squares", "(bindex (a b) (bind c (* a a) (bind d (* b b) (bind numer (+ c d) (bind denom (- c d) (/ numer denom))))))", [([5;0],Val(1)); ([5;1],Val(1)); ([5;2],Val(1)); ([5;3],Val(2)); ([5;4],Val(4)); ([5;5],Err("Division by 0: 50"))]) ] let test () = IbexTester.testEntries (entries @ IntexInterpTest.entries) end