scalatest / scalatest

A testing tool for Scala and Java developers
Apache License 2.0
1.15k stars 333 forks source link

Invalid bounds causes java.lang.InternalError: Malformed class name #1126

Open dabd opened 7 years ago

dabd commented 7 years ago

The following test triggers the mentioned error when the list xs is empty, creating in invalid bound for Gen.choose:

 "test" should "be" in {
    val g =
      for {
        xs <- Gen.listOf(Arbitrary.arbInt.arbitrary)
        n <- Gen.choose(0, xs.length - 1)
      } yield (xs, n)
    forAll(g) {
      case (_, _) => true mustBe true
    }
  }
morgen-peschke commented 7 years ago

This looks like it may have been fixed in 3.02

https://github.com/scalatest/scalatest/issues/992

brandon-leapyear commented 2 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


I'm still seeing this, using

val scala = "2.11.12"
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.0"
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.2"
val scalaTestScalaCheck = "org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0"

The original post fails for me with Malformed class name, as does using nested forAlls

forAll(Gen.choose(0, 1)) { _ =>
  forAll(Gen.choose(1, 0)) { _ < 10 }
}

It's fine for a single forAll:

// org.scalacheck.Gen$Choose$IllegalBoundsError: invalid bounds: low=1, high=0
forAll(Gen.choose(1, 0)) { _ < 10 }