diff options
Diffstat (limited to 'test/assert.rb')
| -rw-r--r-- | test/assert.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/assert.rb b/test/assert.rb index 54b50138e..a4918ce23 100644 --- a/test/assert.rb +++ b/test/assert.rb @@ -65,3 +65,16 @@ def report() print("\n") end +## +# Performs fuzzy check for equality on methods returning floats +# on the basis of the Math::TOLERANCE constant. +def check_float(a, b) + a = a.to_f + b = b.to_f + if a.finite? and b.finite? + (a-b).abs < Math::TOLERANCE + else + true + end +end + |
