(* unit testing framework for Problem Set 2 *) (* use ps2-framework.sml and the ps2-explain.sml to be tested; then type runTests explain; *) val tests = [(1, "%"), (2, "001"), (3, "010"), (4, "100"), (5, "001010"), (6, "010100"), (7, "100001"), (8, "100000011010"), (9, "110001000001000111000")]; fun runStrTest explain (n, s) = (print ("starting test " ^ Int.toString n ^ " - " ^ Str.toString s ^ "\n"); let val e = explain s val t = strExplained e in if Str.equal(s, t) then print "passed\n" else print ("failed: returned explanation is for " ^ Str.toString t ^ "\n") end handle _ => print "failed: exception raised\n") fun runTests explain = let val strTests = map (fn (n, s) => (n, Str.fromString s)) tests in app (runStrTest explain) strTests end;