Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9c096c96c8b6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21f0aa09f5ae
Choose a head ref
  • 3 commits
  • 1 file changed
  • 2 contributors

Commits on Mar 21, 2018

  1. Fix Complex#finite?

    to use real and image value instead of the magnitude to check for finite.
    See ruby/ruby@241ba38 in MRI.
    ChrisBr committed Mar 21, 2018
    Copy the full SHA
    152ef48 View commit details
  2. Fix Complex#infinite?

    and use real and imagine values instead of magnitude to check for infinite.
    See ruby/ruby@65d7479 in MRI.
    ChrisBr committed Mar 21, 2018
    Copy the full SHA
    0b7e88a View commit details
  3. Merge pull request #5101 from ChrisBr/complex/finite

    Fix Complex#finite? and Complex#infinite? failing tests
    headius authored Mar 21, 2018
    Copy the full SHA
    21f0aa0 View commit details
Showing with 16 additions and 13 deletions.
  1. +16 −13 core/src/main/java/org/jruby/RubyComplex.java
29 changes: 16 additions & 13 deletions core/src/main/java/org/jruby/RubyComplex.java
Original file line number Diff line number Diff line change
@@ -1003,39 +1003,42 @@ public IRubyObject finite_p(ThreadContext context) {

// MRI: f_finite_p
public boolean checkFinite(ThreadContext context, IRubyObject value) {
IRubyObject magnitude = magnitude(context);

if (magnitude instanceof RubyInteger || magnitude instanceof RubyRational) {
if (value instanceof RubyInteger || value instanceof RubyRational) {
return true;
}

if (magnitude instanceof RubyFloat) {
return ((RubyFloat) magnitude).finite_p().isTrue();
if (value instanceof RubyFloat) {
return ((RubyFloat) value).finite_p().isTrue();
}

if (magnitude instanceof RubyRational) {
if (value instanceof RubyRational) {
return true;
}

return sites(context).finite.call(context, magnitude, magnitude).isTrue();
return sites(context).finite.call(context, value, value).isTrue();
}

@JRubyMethod(name = "infinite?")
@Override
public IRubyObject infinite_p(ThreadContext context) {
IRubyObject magnitude = magnitude(context);
if (checkInfinite(context, real).isNil() && checkInfinite(context, image).isNil()) {
return context.nil;
}
return RubyFixnum.newFixnum(getRuntime(), 1);
}

if (magnitude instanceof RubyInteger || magnitude instanceof RubyRational) {
public IRubyObject checkInfinite(ThreadContext context, IRubyObject value) {
if (value instanceof RubyInteger || value instanceof RubyRational) {
return context.nil;
}

if (magnitude instanceof RubyFloat) {
return ((RubyFloat) magnitude).infinite_p();
if (value instanceof RubyFloat) {
return ((RubyFloat) value).infinite_p();
}

return sites(context).infinite.call(context, magnitude, magnitude);
return sites(context).infinite.call(context, value, value);
}

private static final ByteList SEP = RubyFile.SLASH;
private static final ByteList _eE = new ByteList(new byte[] { '.', 'e', 'E' }, false);