• KOBAYASHI Shuji's avatar
    Fix dealing with infinity and NaN in `test/assert.rb:assert_float` · 0b6696cc
    KOBAYASHI Shuji authored
    `assert_float` is always passed when expected value and/or actual value are
    infinity or NaN. This behavior seems unintentional.
    
    Before this patch:
    
        assert_float(Float::INFINITY, 1.0)  #=> pass
        assert_float(-Float::INFINITY, 1)   #=> pass
        assert_float(1, 1/0)                #=> pass
        assert_float(1, -1/0)               #=> pass
        assert_float(1.0, Float::NAN)       #=> pass
        assert_float(Float::NAN, 1)         #=> pass
    
    After this patch:
    
        assert_float(Float::INFINITY, 1.0)  #=> fail: Expected 1.0 to be Infinity.
        assert_float(-Float::INFINITY, 1)   #=> fail: Expected 1 to be -Infinity.
        assert_float(1, 1/0)                #=> fail: Expected Infinity to be 1.
        assert_float(1, -1/0)               #=> fail: Expected -Infinity to be 1.
        assert_float(1.0, Float::NAN)       #=> fail: Expected NaN to be 1.0.
        assert_float(Float::NAN, 1)         #=> fail: Expected 1 to be NaN.
    0b6696cc
assert.rb 6.07 KB