Skip to content

Commit

Permalink
check some emptyness invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek committed Aug 20, 2018
1 parent e855055 commit 1d7dcc5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/src/test/scala/cats/tests/ChainSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,19 @@ class ChainSuite extends CatsSuite {
assert((a ++ b).nonEmpty || (a.isEmpty && b.isEmpty))
}
}

test("a.isEmpty == (a eq Chain.nil)") {
assert(Chain.fromSeq(Nil) eq Chain.nil)

forAll { (a: Chain[Int]) =>
assert(a.isEmpty == (a eq Chain.nil))
}
}

test("(nil ++ a) eq a") {
forAll { (a: Chain[Int]) =>
assert((Chain.nil ++ a) eq a)
assert((a ++ Chain.nil) eq a)
}
}
}

0 comments on commit 1d7dcc5

Please sign in to comment.