How about
class Epsilon
@epsilon
def initialize( epsilon )
@epsilon = epsilon
end
def test(actual, excepted)
return (a-b).abs < @epsilon
end
end
class DigitPrecision < Epsilon
def initialize( digitCount )
@epsilon = 0.1 ** (digitCount)
end
end
def assert_equal_float(actual, expected, tester = Epsilon.new(0.00001))
tester.test(actual, expected)
...
end
assert_equal_float(Math.sqrt(2), 1.414, Epsilon.new(0.001))
assert_equal_float(Math.sqrt(2), 1.414, DigitPrecision(3))
> Probably I can code the X digit checking version, but I have no
> good name of the method. Do you have any good idea about the
> name of the method with X digit checking versi
But DigitPrecision is bad name IMHO, and I didn't even dare to answer to
your question :(.
- Aleksi