Skip to content

Commit

Permalink
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/src/main/java/org/jruby/RubyComparable.java
Original file line number Diff line number Diff line change
@@ -69,7 +69,19 @@ public static RubyModule createComparable(Ruby runtime) {
*/
public static int cmpint(ThreadContext context, IRubyObject val, IRubyObject a, IRubyObject b) {
if (val.isNil()) cmperr(a, b);
if (val instanceof RubyFixnum) return RubyNumeric.fix2int((RubyFixnum) val);
if (val instanceof RubyFixnum) {
final int asInt = RubyNumeric.fix2int((RubyFixnum) val);

if (asInt > 0) {
return 1;
}

if (asInt < 0) {
return -1;
}

return 0;
}
if (val instanceof RubyBignum) return ((RubyBignum) val).getValue().signum() == -1 ? -1 : 1;

RubyFixnum zero = RubyFixnum.zero(context.runtime);

0 comments on commit 893aefe

Please sign in to comment.