Skip to content

Commit

Permalink
Removed redundant test-cases (zio#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilu committed May 26, 2019
1 parent a7b9b88 commit 1a4e7e4
Showing 1 changed file with 22 additions and 52 deletions.
74 changes: 22 additions & 52 deletions core/shared/src/test/scala/scalaz/zio/internal/StackBoolSpec.scala
@@ -1,63 +1,33 @@
package scalaz.zio.internal

import org.scalacheck.{ Arbitrary, Gen }
import org.scalacheck.{ Arbitrary, Gen, Prop }
import org.specs2.{ ScalaCheck, Specification }

class StackBoolSpec extends Specification with ScalaCheck {
def is =
"StackBoolSpec".title ^ s2"""
Size tracking $e0
From/to list small identity $e1
From/to list large identity $e2
Small push/pop example $e3
Large push/pop example $e4
Peek/pop identity $e5
From/to list identity $e1
Push/pop example $e2
Peek/pop identity $e3
"""

implicit val booleanGen: Gen[Boolean] = Arbitrary.arbitrary[Boolean]
import Arbitrary._

private val generator: Gen[List[Boolean]] = boolListGen(0, 400)

def e0 =
prop { list: List[Boolean] =>
Prop.forAll(generator) { list: List[Boolean] =>
StackBool(list: _*).size must_== list.length
}.setGen(for {
size <- Gen.choose(0, 100)
g <- Gen.listOfN(size, booleanGen)
} yield g)
}

def e1 =
prop { list: List[Boolean] =>
Prop.forAll(generator) { list: List[Boolean] =>
StackBool(list: _*).toList must_=== list
}.setGen(for {
size <- Gen.choose(0, 32)
g <- Gen.listOfN(size, booleanGen)
} yield g)
}

def e2 =
prop { list: List[Boolean] =>
StackBool(list: _*).toList must_=== list
}.setGen(for {
size <- Gen.choose(0, 400)
g <- Gen.listOfN(size, booleanGen)
} yield g)

def e3 = {
val stack = StackBool()

stack.push(true)
stack.push(true)
stack.push(false)

val v1 = stack.popOrElse(true)
val v2 = stack.popOrElse(false)
val v3 = stack.popOrElse(false)

(v1 must_=== false) and
(v2 must_=== true) and
(v3 must_=== true)
}

def e4 =
prop { list: List[Boolean] =>
Prop.forAll(generator) { list: List[Boolean] =>
val stack = StackBool()

list.foreach(stack.push(_))
Expand All @@ -66,13 +36,10 @@ class StackBoolSpec extends Specification with ScalaCheck {
case (result, flag) =>
result and (stack.popOrElse(!flag) must_=== flag)
}
}.setGen(for {
size <- Gen.choose(100, 400)
g <- Gen.listOfN(size, booleanGen)
} yield g)
}

def e5 =
prop { list: List[Boolean] =>
def e3 =
Prop.forAll(generator) { list: List[Boolean] =>
val stack = StackBool()

list.foreach(stack.push(_))
Expand All @@ -84,8 +51,11 @@ class StackBoolSpec extends Specification with ScalaCheck {

result and (peeked must_=== popped)
}
}.setGen(for {
size <- Gen.choose(100, 400)
g <- Gen.listOfN(size, booleanGen)
} yield g)
}

private def boolListGen(min: Int, max: Int) =
for {
size <- Gen.choose(min, max)
g <- Gen.listOfN(size, Arbitrary.arbitrary[Boolean])
} yield g
}

0 comments on commit 1a4e7e4

Please sign in to comment.