Skip to content

Commit

Permalink
Fix imprecise float comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed May 18, 2009
1 parent ad85771 commit 9fcadcb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions activesupport/test/core_ext/duration_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ def test_since_and_ago_with_fractional_days
Time.stubs(:now).returns Time.local(2000) Time.stubs(:now).returns Time.local(2000)
# since # since
assert_equal 36.hours.since, 1.5.days.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 # ago
assert_equal 36.hours.ago, 1.5.days.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 end


def test_since_and_ago_with_fractional_weeks def test_since_and_ago_with_fractional_weeks
Time.stubs(:now).returns Time.local(2000) Time.stubs(:now).returns Time.local(2000)
# since # since
assert_equal((7 * 36).hours.since, 1.5.weeks.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 # ago
assert_equal((7 * 36).hours.ago, 1.5.weeks.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 end


def test_deprecated_fractional_years def test_deprecated_fractional_years
Expand Down

0 comments on commit 9fcadcb

Please sign in to comment.