Fix Float#eql?

This commit is contained in:
KOBAYASHI Shuji
2019-03-21 21:36:54 +09:00
parent 3f7cd4687f
commit a41b02ab91
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -369,7 +369,7 @@ flo_eql(mrb_state *mrb, mrb_value x)
mrb_get_args(mrb, "o", &y);
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 */
+6
View File
@@ -239,4 +239,10 @@ assert('Float#to_s') do
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)