Comments (7)
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.
from scalatest.
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.
from scalatest.
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.
from scalatest.
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.
from scalatest.
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.
from scalatest.
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 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)"
}
}
}
}
from scalatest.
I wish this would get fixed :(
from scalatest.
Related Issues (20)
- Add a way to run a ScalaCheck test with a given seed HOT 4
- Not Useful scala.MatchError given while failing Tests HOT 2
- Opaque Types don't verify correctly (Maybe ?) HOT 6
- FBounded Polymorphism and `shouldNot compile` giving a false positive HOT 6
- WordSpecLike HOT 3
- Passing position explicitly to test in Scala 3 HOT 5
- Need support for com.vladsch.flexmark:[email protected] HOT 3
- Retry test with delay HOT 5
- assertDoesNotCompile not works when creating mixins HOT 4
- StackDepthException.failedCodeStackDepth returns invalid value `0` when using Future + passing custom implicit position HOT 4
- Passing assert message by-name? HOT 3
- Unexpected compilation warnings: Auto-application to `()` is deprecated. HOT 5
- PrivateMethodTester does not correctly honor type bounds for method arguments HOT 1
- only method not working in Scala 3 Matchers (as List) HOT 1
- InsertionOrderSet performance issue HOT 5
- what's the right way to use scalatest with scalatestplus.junit5? HOT 2
- add back Mockito 4 support? HOT 3
- Shell.run doesn't fail, it would be nice if it could HOT 2
- Execute tasks on SerialExecutionContext outside of a test HOT 1
- Publish artifacts for Scala-Native 0.5.0? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalatest.