
The where block takes precedence over the global scope so if these points
are generally reused for most tests and only deviate in a few, you could
define them globally to the file and then modify individual ones in the
where blocks of code that needs different values.
Hope that helps
On Mon, Aug 29, 2011 at 8:35 AM, Michael Orlitzky
I have a series of unit tests like this,
test_volume1 :: Assertion test_volume1 = assertEqual "volume is correct" True (vol ~= (-1/3)) where p0 = (0, -0.5, 0) p1 = (0, 0.5, 0) p2 = (2, 0, 0) p3 = (1, 0, 1) ...
test_volume2 :: Assertion test_volume2 = assertEqual "volume is correct" True (vol ~= (1/3)) where p0 = (0, -0.5, 0) p1 = (2, 0, 0) p2 = (0, 0.5, 0) p3 = (1, 0, 1) ...
I would like to de-duplicate some of the values in the 'where' clause. Furthermore, I don't want to declare e.g. p0 and p3 at the top level, since later tests may need different values of p0,p3. What I would really like is something like the following. Is it possible?
let p0 = (0, -0.5, 0) p3 = (1, 0, 1) in test_volume1 :: Assertion test_volume1 = assertEqual "volume is correct" True (vol ~= (-1/3)) where p1 = (0, 0.5, 0) p2 = (2, 0, 0) ...
test_volume2 :: Assertion test_volume2 = assertEqual "volume is correct" True (vol ~= (1/3)) where p1 = (2, 0, 0) p2 = (0, 0.5, 0) ...
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Michael Xavier http://www.michaelxavier.net LinkedIn http://www.linkedin.com/pub/michael-xavier/13/b02/a26