Permalink
Browse files

Fix imprecise float comparison

  • Loading branch information...
jeremy committed May 18, 2009
1 parent ad85771 commit 9fcadcbd68a474c265ab1bd1255082c432ef6821
Showing with 4 additions and 4 deletions.
  1. +4 −4 activesupport/test/core_ext/duration_test.rb
@@ -44,20 +44,20 @@ def test_since_and_ago_with_fractional_days
Time.stubs(:now).returns Time.local(2000)
# since
assert_equal 36.hours.since, 1.5.days.since
- assert_equal((24 * 1.7).hours.since, 1.7.days.since)
+ assert_in_delta((24 * 1.7).hours.since, 1.7.days.since, 0.01)
# ago
assert_equal 36.hours.ago, 1.5.days.ago
- assert_equal((24 * 1.7).hours.ago, 1.7.days.ago)
+ assert_in_delta((24 * 1.7).hours.ago, 1.7.days.ago, 0.01)
end
def test_since_and_ago_with_fractional_weeks
Time.stubs(:now).returns Time.local(2000)
# since
assert_equal((7 * 36).hours.since, 1.5.weeks.since)
- assert_equal((7 * 24 * 1.7).hours.since, 1.7.weeks.since)
+ assert_in_delta((7 * 24 * 1.7).hours.since, 1.7.weeks.since, 0.01)
# ago
assert_equal((7 * 36).hours.ago, 1.5.weeks.ago)
- assert_equal((7 * 24 * 1.7).hours.ago, 1.7.weeks.ago)
+ assert_in_delta((7 * 24 * 1.7).hours.ago, 1.7.weeks.ago, 0.01)
end
def test_deprecated_fractional_years

0 comments on commit 9fcadcb

Please sign in to comment.