File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
jvm/src/test/scala/org/scalacheck
src/main/scala/org/scalacheck Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,20 @@ object GenSpecification extends Properties("Gen") {
103103
104104 import Double .{MinValue , MaxValue }
105105 property(" choose-large-double" ) = forAll(choose(MinValue , MaxValue )) { x =>
106- MinValue <= x && x <= MaxValue
106+ MinValue <= x && x <= MaxValue && ! x.isNaN
107+ }
108+
109+ import Double .{NegativeInfinity , PositiveInfinity }
110+ property(" choose-infinite-double" ) = {
111+ forAll(Gen .choose(NegativeInfinity , PositiveInfinity )) { x =>
112+ NegativeInfinity <= x && x <= PositiveInfinity && ! x.isNaN
113+ }
114+ }
115+
116+ property(" choose-infinite-double-fix-zero-defect-379" ) = {
117+ Prop .forAllNoShrink(listOfN(3 , choose(NegativeInfinity , PositiveInfinity ))) { xs =>
118+ xs.exists(_ != 0d )
119+ }
107120 }
108121
109122 property(" choose-xmap" ) = {
Original file line number Diff line number Diff line change @@ -399,6 +399,12 @@ object Gen extends GenArities{
399399 new Choose [Double ] {
400400 def choose (low : Double , high : Double ) =
401401 if (low > high) throw new IllegalBoundsError (low, high)
402+ else if (low == Double .NegativeInfinity )
403+ frequency(1 -> const(Double .NegativeInfinity ),
404+ 9 -> choose(Double .MinValue , high))
405+ else if (high == Double .PositiveInfinity )
406+ frequency(1 -> const(Double .PositiveInfinity ),
407+ 9 -> choose(low, Double .MaxValue ))
402408 else gen(chDbl(low,high))
403409 }
404410
You can’t perform that action at this time.
0 commit comments