我正在尝试实现一个测试函数来比较并在它们不相等时显示错误消息:
exception AssertionErrorException of string
fun assert(testName, actual, expect) : bool =
if actual = expect
then true
else raise (AssertionErrorException (testName ^ " failed. actual: " ^ actual
^ ", expect: " ^ expect ));
不幸的是,如果我使用非字符串参数调用它,它就不起作用:
assert("test1", SOME [], NONE);
无法编译,报错信息为:
Error: operator and operand don't agree [tycon mismatch]
operator domain: string * string * string
operand: string * 'Z list option * 'Y option
in expression:
assert ("test1",SOME nil,NONE)
如何解决?