纯粹测试STM功能
我最近开始在我的一个项目中使用 STM 来处理某些部分,但我在弄清楚如何测试它时遇到了困难。
我在这些函数中没有 IO,希望我可以编写 QuickCheck 属性来测试事物,但“原子地”(STM a -> IO a)似乎是从 STM monad 中获取任何内容的唯一方法。
这可能吗,还是我应该在 HUnit 中编写测试?
I've recently started using STM for some bits in a project of mine, but I'm having trouble figuring out how to test it.
I have no IO in these functions and was hoping I could write QuickCheck properties to test things, but "atomically" (STM a -> IO a) seems to be the only way to get anything out of the STM monad.
Is this possible, or should I just write my tests in HUnit instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用quickcheck测试IO操作: http://hackage.haskell.org/packages/archive/QuickCheck/2.4.1.1/doc/html/Test-QuickCheck-Monadic.html
You can test IO actions with quickcheck: http://hackage.haskell.org/packages/archive/QuickCheck/2.4.1.1/doc/html/Test-QuickCheck-Monadic.html