Skip to content

Commit

Permalink
hw3 test_parse refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vMaroon committed Jun 25, 2024
1 parent 9a5568a commit edca1b1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Spr24/HW/Homework3/test_parse.sml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use "hw3_q3.sml";
smlnj test_parse.sml
*)

exception TestFailure of string;
let
exception TestFailure of string;

local
fun sexp_to_string (ATOM(SYMBOL s)) = s
| sexp_to_string (ATOM NIL) = "NIL"
| sexp_to_string (CONS (x, y)) = "(" ^ sexp_to_string x ^ "." ^ sexp_to_string y ^ ")";
in
fun assert_equal (expected, actual, msg) =
if expected = actual then ()
else raise TestFailure (msg ^ ": expected " ^ sexp_to_string expected ^ ", but got " ^ sexp_to_string actual);
end;
local
fun sexp_to_string (ATOM(SYMBOL s)) = s
| sexp_to_string (ATOM NIL) = "NIL"
| sexp_to_string (CONS (x, y)) = "(" ^ sexp_to_string x ^ "." ^ sexp_to_string y ^ ")";
in
fun assert_equal (expected, actual, msg) =
if expected = actual then ()
else raise TestFailure (msg ^ ": expected " ^ sexp_to_string expected ^ ", but got " ^ sexp_to_string actual);
end;

let
fun run_tests tests =
let
fun runTest (name, test) =
Expand Down

0 comments on commit edca1b1

Please sign in to comment.