Skip to content

Commit

Permalink
added tests for whenA and unlessA
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed Mar 27, 2017
1 parent 5b5eea8 commit e44663c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/src/test/scala/cats/tests/ApplicativeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package tests
import cats.Applicative


class ApplicativeCheck extends CatsSuite {
class ApplicativeTests extends CatsSuite {

test("replicateA creates a List of 'n' copies of given Applicative 'fa'") {

Expand All @@ -13,4 +13,29 @@ class ApplicativeCheck extends CatsSuite {
A.replicateA(5, fa) should === (Some(List(1,1,1,1,1)))

}
}

test("whenA return given argument when cond is true") {
forAll { (l: List[Int]) =>
l.whenA(true) should === (List.fill(l.length)(()))
}
}

test("whenA lift Unit to F when cond is false") {
forAll { (l: List[Int]) =>
l.whenA(false) should === (List(()))
}
}

test("unlessA return given argument when cond is false") {
forAll { (l: List[Int]) =>
l.unlessA(false) should === (List.fill(l.length)(()))
}
}

test("unlessA lift Unit to F when cond is true") {
forAll { (l: List[Int]) =>
l.unlessA(true) should === (List(()))
}
}

}

0 comments on commit e44663c

Please sign in to comment.