(* 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, "1"), (3, "11"), (4, "110"), (5, "110110"), (6, "11101110"), (7, "111011100"), (8, "111011111010"), (9, "1111011111001"), (10, "1111011101001111110111010011")] 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