Hi Kevin,
No worries. I'm curious what ScalaCheck's check does if it returns
Unit but doesn't throw an exception.
By the way you might be interested in org.scalactic.anyvals coming in
3.0.0, which has positive numeric types. It is currently available
only as a milestone release, 3.0.0-M3, but I'm hoping to get RC1 out
this week. Here's an example:
scala> import org.scalactic.anyvals._
import org.scalactic.anyvals._
scala> PosZInt(0)
res0: org.scalactic.anyvals.PosZInt = PosZInt(0)
scala> PosZInt(1)
res1: org.scalactic.anyvals.PosZInt = PosZInt(1)
scala> PosZInt(Int.MaxValue)
res2: org.scalactic.anyvals.PosZInt = PosZInt
(2147483647)
scala> PosZInt(-1)
<console>:11: error: PosZInt.apply can only be invoked on a
non-negative (i >= 0) integer literal, like PosZInt(42).
PosZInt(-1)
^
scala> PosZInt(Int.MinValue)
<console>:11: error: PosZInt.apply can only be invoked on a
non-negative (i >= 0) integer literal, like PosZInt(42).
PosZInt(Int.MinValue)
^
For literals, you get a compiler error. For non-literals, you'll get
an Option (using the PosZInt.from factory method). I think you might
want an error message though from the looks of your code. Anyway,
since you're dealing with validating positive Ints (and zero) I
thought I'd mention this. I also haven't published Scaladoc yet for
3.0.0, but you can get the idea here by reading the Scaladoc source
here:
https://github.com/scalatest/scalatest/blob/2.3.x/scalactic-macro/src/main/scala/org/scalactic/anyvals/PosZInt.scala
Bill
On Mon, Jun 22, 2015 at 11:45 AM, Kevin Meredith