简体   繁体   English

针对任一的美味 HUnit 测试

[英]Tasty HUnit test against Either

I am fairly new to Haskell, and I was wondering if there is a way to test a pattern match, as in erlang.我对 Haskell 相当陌生,我想知道是否有一种方法可以测试模式匹配,就像在 erlang 中一样。 An example is a function that returns an Either ab, Can I match against Left b, whilst ignoring b itself?一个例子是一个函数,它返回一个或者 ab,我可以匹配左 b,同时忽略 b 本身吗?

In my case, I have Either String Error.就我而言,我有任何字符串错误。 I simply want to test if an error occurs, but it's a bit tedious to write out the entire error text for each test case, so I simply want to assert that it in fact does return a Right error.我只是想测试是否发生错误,但是为每个测试用例写出整个错误文本有点乏味,所以我只想断言它实际上确实返回了一个 Right 错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM