0l should be >= (0)
Does not compile:
overloaded method value should with alternatives:
[error] (endWithWord: org.scalatest.words.EndWithWord)(implicit ev: <:<[Long,String])HyperLogLogCommandsSpec.this.ResultOfEndWithWordForString <and>
[error] (startWithWord: org.scalatest.words.StartWithWord)(implicit ev: <:<[Long,String])HyperLogLogCommandsSpec.this.ResultOfStartWithWordForString <and>
[error] (includeWord: org.scalatest.words.IncludeWord)(implicit ev: <:<[Long,String])HyperLogLogCommandsSpec.this.ResultOfIncludeWordForString <and>
[error] (notExist: org.scalatest.words.ResultOfNotExist)(implicit existence: org.scalatest.enablers.Existence[Long])Unit <and>
[error] (existWord: org.scalatest.words.ExistWord)(implicit existence: org.scalatest.enablers.Existence[Long])Unit <and>
[error] (containWord: org.scalatest.words.ContainWord)org.scalatest.words.ResultOfContainWord[Long] <and>
[error] (haveWord: org.scalatest.words.HaveWord)HyperLogLogCommandsSpec.this.ResultOfHaveWordForExtent[Long] <and>
[error] (beWord: org.scalatest.words.BeWord)HyperLogLogCommandsSpec.this.ResultOfBeWordForAny[Long] <and>
[error] (inv: org.scalactic.TripleEqualsSupport.TripleEqualsInvocationOnSpread[Long])(implicit ev: Numeric[Long])Unit <and>
[error] [U](inv: org.scalactic.TripleEqualsSupport.TripleEqualsInvocation[U])(implicit constraint: org.scalactic.Constraint[Long,U])Unit <and>
[error] (notWord: org.scalatest.words.NotWord)org.scalatest.words.ResultOfNotWordForAny[Long] <and>
[error] [TYPECLASS1[_], TYPECLASS2[_]](rightMatcherFactory2: org.scalatest.matchers.MatcherFactory2[Long,TYPECLASS1,TYPECLASS2])(implicit typeClass1: TYPECLASS1[Long], implicit typeClass2: TYPECLASS2[Long])Unit <and>
[error] [TYPECLASS1[_]](rightMatcherFactory1: org.scalatest.matchers.MatcherFactory1[Long,TYPECLASS1])(implicit typeClass1: TYPECLASS1[Long])Unit <and>
[error] (rightMatcherX1: org.scalatest.matchers.Matcher[Long])Unit
[error] cannot be applied to (org.scalatest.matchers.Matcher[Int])
[error] 0l should be >= (0)
This works fine:
0l.toInt should be >= (0)
Hmm, I'm actually not sure this is a bug as this works.
0l should be >= (0l)
However, it would be nice if the right hand side could be implicitly converted to long.
I've thought about doing that, but haven't yet. What you need to do is make them both long, as you discovered. I'll continue to think about it.
This one I still would like to make more open to cooperating numeric types, but it will need to wait until we have the cooperating numerics in Scalactic, which will be 3.0.
I struggled with this for ... 30? minutes, until I noticed the compilation & IDE errors were because of wrong types — because of this GitHub issue I think. Now, this works fine:
someVariableOfTypeLong must be > 0L
That is, specifying 0L (type Long) instead of just 0 (type Int) solved the problem for me.
A friendlier compilation error or IntelliJ highlighting error, would have been helpful. Currently IntelliJ Idea just says "cannot resolve function with such signature" when I hover the error-underlined word _"must"_ in the source code (in the 0 version, i.e. RHS=Integer not Long). And the Scala compiler itself says _"overloaded method value must with alternatives:"_ and then prints a large blob of text: about 10 different functions and their signatures. Neither Idea nor the Scala compiler is helpful in troubleshooting the problem here (not to me at least). — Perhaps this is hard for the ScalaTest devs to do anything about though.
Anyway thanks for building ScalaTest, it's my favorite Scala + Java test framework.
Not compiling here is better, IMO, than the behavior of mustBe which will compile but produce unexpected results when the static types being compared are not identical:
```import org.scalatest._
import MustMatchers._
import scala.concurrent.duration._
class Test extends WordSpec {
"Duration/FiniteDuration mixed" when {
"tested with must" should {
"work" in {
60.seconds.asInstanceOf[Duration] must be >= (60.seconds) // Fails to compile
}
}
"tested with mustBe" should {
"work" in {
60.seconds.asInstanceOf[Duration] mustBe >= (60.seconds) // Fails with "60 seconds was not equal to >= (60 seconds)"
}
}
}
}
```
I wish this would get fixed :(
Long is taking too Long I guess! Any update on this? If you want to test any time-based tool which uses Long then you would have this problem. I was assuming at least the primitive types are fully supported by now.