Skip to content

Commit

Permalink
Ensure that two chunks can be compared for equality and hash code zio…
Browse files Browse the repository at this point in the history
…#1159 (zio#1163)

* Remove extraneous ZIO from home page and sub pages zio#961

* Ensure that two chunks can be compared for equality and hash code zio#1159

* zio#1163 'testReflexivity' method renamed

* removed never used values

* add a line in the 'spec string' for each test zio#1163
  • Loading branch information
Vilkina authored and jdegoes committed Jul 11, 2019
1 parent 6180669 commit 9dc6498
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions streams/jvm/src/test/scala/zio/stream/ChunkSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class ChunkSpec extends Specification with ScalaCheck {
toArray $toArray
foreach $foreach
concat chunk $concat
chunk transitivity $testTransitivity
chunk symmetry $testSymmetry
chunk reflexivity $testReflexivity
chunk negation $testNegation
chunk substitutivity $testSubstitutivity
chunk consistency $hashConsistency
An Array-based chunk that is filtered empty and mapped must not throw NPEs. $nullArrayBug
toArray on concat of a slice must work properly. $toArrayOnConcatOfSlice
toArray on concat of empty and integers must work properly. $toArrayOnConcatOfEmptyAndInts
Expand Down Expand Up @@ -139,4 +145,41 @@ class ChunkSpec extends Specification with ScalaCheck {

sum must_=== c.toSeq.sum
}

def testTransitivity = {
val c1 = Chunk(1, 2, 3)
val c2 = Chunk(1, 2, 3)
val c3 = Chunk(1, 2, 3)
((c1 == c2) && (c2 == c3) && (c1 == c3)) must beTrue
}

def testSymmetry = {
val c1 = Chunk(1, 2, 3)
val c2 = Chunk(1, 2, 3)
((c1 == c2) && (c2 == c1)) must beTrue
}

def testReflexivity = {
val c1 = Chunk(1, 2, 3)
((c1 == c1)) must beTrue
}

def testNegation = {
val c1 = Chunk(1, 2, 3)
val c2 = Chunk(1, 2, 3)
(c1 != c2 == !(c1 == c2)) must beTrue
}

def testSubstitutivity = {
val c1 = Chunk(1, 2, 3)
val c2 = Chunk(1, 2, 3)
((c1 == c2) && (c1.toString == c2.toString)) must beTrue
}

def hashConsistency = {
val c1 = (1, 2, 3)
val c2 = (1, 2, 3)
((c1 == c2) && (c1.hashCode == c2.hashCode)) must beTrue
}

}

0 comments on commit 9dc6498

Please sign in to comment.