在 Scala 规范中,“必须”是什么?功能?
我正在进行一些规格测试,并试图了解“必须”功能是什么以及它的作用。
我无法在规范源中的任何地方找到它的声明或实现,并且我试图了解它的作用。
以下是它的一些示例用法:
"hello world".size must be equalTo(11)
"hello world" must be matching("h.* w.*")
stack.push(11) must throwAn[Error]
在我看来,“must”将函数作为参数,但我想知道“must”的实际签名,以及它对其参数的作用。
有人能指出我正确的方向吗?
谢谢!
I'm working with some Specs tests and I'm trying to understand what the "must" function is, and what it does.
I am unable to find its declaration or implementation anywhere in the specs source, and I'm trying to understand what it does.
Here are some example usages of it:
"hello world".size must be equalTo(11)
"hello world" must be matching("h.* w.*")
stack.push(11) must throwAn[Error]
It looks to me like "must" takes a function as an argument, but I'd like to know the actual signature of "must", and what it does with its argument.
Can anyone point me in the right direction?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至少在 Specs2.0 中,您会在 org.specs2.matcher.MustExpectable
MustExpectation
特征在这里声明相关的隐式转换:At least with Specs2.0, you will find the definition of must in org.specs2.matcher.MustExpectable
The
MustExpectation
trait is here to declare the relevant implicit conversions:有关于 MustMatchers 的文档,有关于
must
和应该
。There's the documentation on MustMatchers, there are detailed explanations on the usage of
must
andshould
.