Remove any precision problem by comparing the float values

Rational values are move precise than float values so when comparing
rationals values may be off by a few units that are hard to assert
equality. Let's make sure we are comparing the float value with float
values.
上级 109aad7c
......@@ -114,13 +114,15 @@ def test_sec_fraction
assert_equal Rational(1, 1_000_000_000), time.sec_fraction
time = Time.utc(2016, 4, 23, 0, 0, 0.000_000_001)
assert_equal Rational(1, 1_000_000_000), time.sec_fraction
assert_kind_of Rational, time.sec_fraction
assert_equal 0.000_000_001, time.sec_fraction.to_f
time = Time.utc(2016, 4, 23, 0, 0, 0, Rational(1, 1_000))
assert_equal Rational(1, 1_000_000_000), time.sec_fraction
time = Time.utc(2016, 4, 23, 0, 0, 0, 0.001)
assert_equal Rational(1, 1_000_000_000), time.sec_fraction
assert_kind_of Rational, time.sec_fraction
assert_equal 0.001.to_r / 1000000, time.sec_fraction.to_f
end
def test_beginning_of_day
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册