Skip to content

Commit

Permalink
Changed assertions for better error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
olavolav committed Jul 5, 2014
1 parent bd4208b commit b4f94b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/test_helper.rb
Expand Up @@ -18,21 +18,21 @@


def assert_approximate_equality(expected, real, delta=0.01)
assert (expected - real).abs < delta
assert (expected - real).abs < delta, "#{expected} and #{real} are not equal enough"
end

def assert_approximate_equality_of_nested_list(expected, real, delta=0.01)
if expected.respond_to?(:each) && real.respond_to?(:each) && expected.length == real.length
[expected, real].transpose.each{ |ex, re| assert_approximate_equality_of_nested_list(ex, re, delta) }
else
assert expected == real
assert_equal expected, real
end
end

def assert_equality_of_nested_list(expected, real)
if expected.respond_to?(:each) && real.respond_to?(:each) && expected.length == real.length
[expected, real].transpose.each{ |ex, re| assert_equality_of_nested_list(ex, re) }
else
assert expected == real
assert_equal expected, real
end
end

0 comments on commit b4f94b9

Please sign in to comment.