Commit a41b02ab authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Fix `Float#eql?`

parent 3f7cd468
...@@ -369,7 +369,7 @@ flo_eql(mrb_state *mrb, mrb_value x) ...@@ -369,7 +369,7 @@ flo_eql(mrb_state *mrb, mrb_value x)
mrb_get_args(mrb, "o", &y); mrb_get_args(mrb, "o", &y);
if (!mrb_float_p(y)) return mrb_false_value(); if (!mrb_float_p(y)) return mrb_false_value();
return mrb_bool_value(mrb_float(x) == (mrb_float)mrb_fixnum(y)); return mrb_bool_value(mrb_float(x) == mrb_float(y));
} }
/* 15.2.9.3.7 */ /* 15.2.9.3.7 */
......
...@@ -239,4 +239,10 @@ assert('Float#to_s') do ...@@ -239,4 +239,10 @@ assert('Float#to_s') do
end end
end end
assert('Float#eql?') do
assert_true(5.0.eql?(5.0))
assert_false(5.0.eql?(5))
assert_false(5.0.eql?("5.0"))
end
end # const_defined?(:Float) end # const_defined?(:Float)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment