(* 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 BINDEX_INTERP = sig exception EvalError of string val run : Bindex.pgm -> int list -> int end module type BINDEX_TEST = sig val test : unit -> unit end module BindexInterpTest (BindexInterp: BINDEX_INTERP): BINDEX_TEST = struct open IntexInterpTest module BindexTester = MakeTester ( struct type prog = string type arg = int type res = result let trial progString args = try Val(BindexInterp.run (Bindex.stringToPgm progString) args) with BindexInterp.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 () = BindexTester.testEntries (entries @ IntexInterpTest.entries) end