/tests/src/test/scala/scalaz/FunctorTest.scala

http://github.com/scalaz/scalaz · Scala · 32 lines · 25 code · 7 blank · 0 comment · 0 complexity · 9d3844f08b94ea05945d1071e82165d7 MD5 · raw file

  1. package scalaz
  2. import std.AllInstances._
  3. import std.option.some
  4. import syntax.functor._
  5. import org.scalacheck.Prop.forAll
  6. object FunctorTest extends SpecLite {
  7. "mapply" in {
  8. 1.mapply(some((a: Int) => a)) must_===(some(1))
  9. }
  10. "map" in {
  11. (some(1) (1+)) must_===(some(2))
  12. }
  13. "strength" in {
  14. some(1).strengthL(2) must_===(some((2, 1)))
  15. some(1).strengthR(2) must_===(some((1, 2)))
  16. }
  17. "fpair" in {
  18. some(1).fpair must_===(some((1, 1)))
  19. }
  20. "widen" ! forAll { ola: Option[List[Int]] =>
  21. import std.iterable._
  22. val oia: Option[Iterable[Int]] = ola
  23. ola.widen[Iterable[Int]] must_===(oia)
  24. }
  25. }