Search code examples
scalaintscalatest

PosZInt and PosInt in scala?


In ScalaTest configuration.scala, methods are taking PosInt rather than Int. eg: MinSuccessful(value: PosInt) What's the difference among them?

My research on line shows that they belong to Anyvals. How does that benefit the scala test process?


Solution

  • They are just small wrappers around ints that verify at compile-time that the value is positive (or non-negative for PosZInt). See the documentation here.

    The purpose is to prevent you from doing, for example, MinSuccessful(-1).