Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我将此测试定义为:
val neg = Test (fn x => x < 0, "neg");
我该如何测试这个?我试过了
neg 3;
但我得到一个错误......
从外观上看,它Test是一个值构造函数,因此您应该先“解包”它,然后才能访问其中的对。
Test
像这样的东西应该可以完成这项工作
val Test (f, s) = Test (fn x => x < 0, "neg") f 3
您可以通过一个解包测试并运行它的函数来做到这一点:
fun runtest Test(f,s) x = f x
然后你会做
runtest neg 3