Code Monkey home page Code Monkey logo

Comments (7)

curreli avatar curreli commented on May 10, 2024 1

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.

kajmagnus avatar kajmagnus commented on May 10, 2024 1

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.

seyed avatar seyed commented on May 10, 2024 1

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.

bvenners avatar bvenners commented on May 10, 2024

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.

bvenners avatar bvenners commented on May 10, 2024

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.

jameskoch avatar jameskoch commented on May 10, 2024

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.

aliakhtar avatar aliakhtar commented on May 10, 2024

I wish this would get fixed :(

from scalatest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.