Google Groups

Re: [scalatest-users] plusOrMinus strangeness


Bill Venners Mar 2, 2010 8:10 AM
Posted in group: scalatest-users
Hi,

You must use plusOrMinus with "be" not "equal". "equal" always
compares for equality by invoking == on one object, passing in the
other. "be" does different things depending on what object is being
passed. So try:

0.5 must be (0.5 plusOrMinus 0.1)

Bill

On Tue, Mar 2, 2010 at 6:33 AM, ido <idom...@gmail.com> wrote:
> @RunWith(classOf[JUnitRunner])
> class PearsonSpecification extends FlatSpec with ShouldMatchers {
>
>    "test1" should "plusminus" in {
>        0.5 should equal (0.5 plusOrMinus 0.1)
>    }
>
>    "test2" should "plusminus" in {
>        0.5 should equal (0.5)
>    }
> }
>
>
> test2 passes but
> for test1 I get:
> org.scalatest.TestFailedException: 0.5 did not equal
> DoubleTolerance(0.5,0.1)
>
> Which I don't understand.
> I use scalatest-1.0.1-for-scala-2.8.0.Beta1-SNAPSHOT
>
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
>

--
Bill Venners
Artima, Inc.
http://www.artima.com