Merge pull request #1874 from ksss/float-plus

float + nil should be raise TypeError
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-03-17 00:13:24 +09:00
2 changed files with 8 additions and 6 deletions
+5 -6
View File
@@ -1306,15 +1306,14 @@ num_cmp(mrb_state *mrb, mrb_value self)
* and <code>other</code>.
*/
static mrb_value
flo_plus(mrb_state *mrb, mrb_value self)
flo_plus(mrb_state *mrb, mrb_value x)
{
mrb_float x, y;
mrb_value y;
x = mrb_float(self);
mrb_get_args(mrb, "f", &y);
return mrb_float_value(mrb, x + y);
mrb_get_args(mrb, "o", &y);
return mrb_float_value(mrb, mrb_float(x) + mrb_to_flo(mrb, y));
}
/* ------------------------------------------------------------------------*/
void
mrb_init_numeric(mrb_state *mrb)
+3
View File
@@ -15,6 +15,9 @@ assert('Float#+', '15.2.9.3.1') do
assert_float(3.123456789, a)
assert_float(4.123456789, b)
assert_raise(TypeError){ 0.0+nil }
assert_raise(TypeError){ 1.0+nil }
end
assert('Float#-', '15.2.9.3.2') do