fix r54193

* numeric.c (fix_cmp): invert the result as the comarison is
  inverted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-03-19 12:53:36 +00:00
parent b01312ab97
commit 448b4eb117
3 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Sat Mar 19 21:53:35 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_cmp): invert the result as the comarison is
inverted.
Sat Mar 19 18:32:00 2016 Kenta Murata <mrkn@mrkn.jp>
* numeric.c (int_to_f): raise NotImplementedError when a receiver

View File

@ -3425,7 +3425,12 @@ fix_cmp(VALUE x, VALUE y)
return INT2FIX(-1);
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
return rb_big_cmp(y, x);
VALUE cmp = rb_big_cmp(y, x);
switch (cmp) {
case INT2FIX(+1): return INT2FIX(-1);
case INT2FIX(-1): return INT2FIX(+1);
}
return cmp;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
return rb_integer_float_cmp(x, y);

View File

@ -214,6 +214,7 @@ class TestFixnum < Test::Unit::TestCase
assert_equal(0, 1 <=> 1)
assert_equal(-1, 1 <=> 4294967296)
assert_equal(-1, 1 <=> 1 << 100)
assert_equal(0, 1 <=> 1.0)
assert_nil(1 <=> nil)