Skip to content

Instantly share code, notes, and snippets.

@bvenners
Created February 4, 2014 23:30
Show Gist options
  • Save bvenners/8814587 to your computer and use it in GitHub Desktop.
Save bvenners/8814587 to your computer and use it in GitHub Desktop.
Simplicity saves time
import org.specs2.ScalaCheck
import org.specs2.mutable._
case class Box(first: String)
class FooSpec extends Specification with ScalaCheck {
"this should compile without obfuscated error messages" in {
check { (left: String, right: String) =>
import java.lang.String
if (false)
null == null
else
Box("").first eq ""
}
}
}
[info] Compiling 1 Scala source to /Users/bv/nobkp/delus/specs2Project/target/scala-2.11.0-M8/test-classes...
[error] type mismatch;
[error] found : => Any
[error] required: AnyRef
[error] Note that <byname> extends Any, not AnyRef.
[error] Such types can participate in value classes, but instances
[error] cannot appear in singleton types or in reference comparisons.
[error] one error found
import org.scalatest._
import prop.Checkers
case class Box(first: String)
class FooSpec extends WordSpec with Checkers {
"this should compile without obfuscated error messages" in {
check { (left: String, right: String) =>
import java.lang.String
if (false)
null == null
else
Box("").first eq ""
}
}
}
[info] Compiling 1 Scala source to /Users/bv/nobkp/delus/specs2Project/target/scala-2.11.0-M8/test-classes...
[info] FooSpec:
[info] - this should compile without obfuscated error messages
[info] ScalaTest
[info] Run completed in 348 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 3 s, completed Feb 4, 2014 3:27:03 PM
sbt build file:
scalaVersion := "2.11.0-M8"
libraryDependencies += "org.specs2" % "specs2-scalacheck_2.11.0-M8" % "2.3.7" % "test"
libraryDependencies += "org.scalatest" % "scalatest_2.11.0-M8" % "2.1.0-RC2" % "test"
libraryDependencies += "org.scalacheck" % "scalacheck_2.11.0-M8" % "1.11.3" % "test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment