makestring ML, . Poly/ML PolyML.makestring, , .
fun assert(testName, actual, expect) =
if actual = expect
then true
else raise AssertionErrorException(testName ^ " failed. actual: " ^
PolyML.makestring actual ^ ", expect: " ^
PolyML.makestring expect);
,
assert("test1", SOME [], NONE);
Exception-
AssertionErrorException "test1 failed. actual: SOME [], expect: NONE"
raised
, , . , , PolyML.makestring , , , "?". , , .
fun assert(testName, actual, expect, toString) =
if actual = expect
then true
else raise AssertionErrorException(testName ^ " failed. actual: " ^
toString actual ^ ", expect: " ^ toString expect );
, . Poly/ML PolyML.makestring.
assert("test2", (1,2,3), (1,2,4), PolyML.makestring);
Exception-
AssertionErrorException
"test2 failed. actual: (1, 2, 3), expect: (1, 2, 4)" raised
SML, .
assert("test2", (1,2,3), (1,2,4),
fn (a,b,c) =>
String.concat["(", Int.toString a, ",", Int.toString b,
",", Int.toString c, ")"]);
, .