Skip to content

Commit

Permalink
Updated test about ValueConverter.flatMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogach committed May 18, 2013
1 parent 6df701d commit 99969c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/test/scala/ValueConverterTest.scala
Expand Up @@ -3,7 +3,7 @@ package org.rogach.scallop
import org.scalatest.FunSuite
import scala.reflect.runtime.universe.TypeTag

class ValueConverterTest extends FunSuite {
class ValueConverterTest extends FunSuite with UsefulMatchers {
throwError.value = true

test ("optional value - flatMap way") {
Expand All @@ -17,11 +17,14 @@ class ValueConverterTest extends FunSuite {
val foo = opt[Option[String]]()
}
val conf1 = getcf(Nil)
conf1.foo.get === None
conf1.foo.get ==== None

val conf2 = getcf(List("-f"))
conf2.foo.get === Some(None)
// bad corner case - flatMap doesn't apply when previous converter returned None
conf2.foo.get ==== None

val conf3 = getcf(List("-f", "bar"))
conf3.foo.get === Some(Some("bar"))
conf3.foo.get ==== Some(Some("bar"))
}

/** https://github.com/Rogach/scallop/issues/57 */
Expand Down

0 comments on commit 99969c9

Please sign in to comment.