Scalactic User Guide Custom equality Default equality Constrained equality Tolerance Normalization The Explicitly DSL Or and Every Requirements Snapshots TimesOnInt |
Normalization
The Scalactic
For example, to normalize import org.scalactic._ val truncated = new Normalization[Double] { def normalized(d: Double) = d.floor }
Given this definition you could use it with the import org.scalatest._ import Matchers._ import TypeCheckedTripleEquals._ (2.1 should === (2.0)) (after being truncated)
Note that to use a
If you make the implicit val doubleNormalization = truncated import NormMethods._ val d = 2.1 d.norm // returns 2.0 Uniformity
An important subtype of
For example, to normalize import org.scalactic._
Given this definition you could use it with the import org.scalatest._ import Matchers._
If you make the implicit val doubleUniformity = truncated import NormMethods._
As mentioned previously, by creating a Next, learn about The Explicitly DSL. |
Scalactic is brought to you by Bill Venners, with
contributions from several other folks. It is sponsored by
Artima, Inc.
ScalaTest is free, open-source software
released under the Apache
2.0 license.
Copyright © 2009-2024 Artima, Inc. All Rights Reserved.