Skip to content

Instantly share code, notes, and snippets.

@ivmaykov
Created July 11, 2014 22:57
Show Gist options
  • Save ivmaykov/a94c81566f77d66fa82b to your computer and use it in GitHub Desktop.
Save ivmaykov/a94c81566f77d66fa82b to your computer and use it in GitHub Desktop.
import org.scalatest.{Matchers, FlatSpec}
case class Foo(bar: Option[String])
object Foo {
// Unexpectedly, Foo.Default.bar is null at runtime. Swapping the order of Default and Unknown, or making
// either of them a lazy val, fixes the issue.
val Default = Foo(Unknown)
val Unknown = None
}
class FooTest extends FlatSpec with Matchers {
"Foo.Default.bar" should "be None" in {
Foo.Default.bar should equal (None)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment