rational.c: ensure to be Rational

* rational.c (f_round_common): Rational is expected to be returned by
  Rational#*, but mathn.rb breaks that assumption.  [ruby-core:56177]
  [Bug #8687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-07-26 02:42:26 +00:00
parent 0f12658995
commit 8974d5aaa7
3 changed files with 111 additions and 1 deletions

View file

@ -1285,6 +1285,10 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
return self;
}
if (!k_rational_p(s)) {
s = f_rational_new_bang1(CLASS_OF(self), s);
}
s = (*func)(s);
s = f_div(f_rational_new_bang1(CLASS_OF(self), s), b);