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: a5f8721255f4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: df012fa21143
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Sep 15, 2015

  1. New spec: Enumerable#find_index should use #== semantics for testing …

    …equality
    
    This matches the behavior of MRI.
    alexdowad committed Sep 15, 2015
    Copy the full SHA
    2eefaef View commit details
  2. RubyFixnum.equals performs conversion on Float arguments

    The 'equals' method is used as an equivalent of `self#==`. `Fixnum#==` converts
    Float arguments, so `RubyFixnum.equals` should do so too.
    
    `RubyFixnum.op_equalOther` also converts `Bignum`s which are passed in, so maybe
    `RubyFixnum.equals` should do so too. But then again, when can a `Bignum` ever be
    equal to a `Fixnum`? In MRI, I'm pretty sure that is impossible, but maybe JRuby
    doesn't always "fixize" `Bignum`s?
    
    That is a question for someone else to answer. For now, this fixes a bug.
    alexdowad committed Sep 15, 2015
    Copy the full SHA
    4eee14a View commit details

Commits on Sep 16, 2015

  1. Merge pull request #3325 from alexdowad/fix_fixnum_equals

    "[2].to_enum.find_index(2.0)" returns 0 (to match MRI behavior)
    kares committed Sep 16, 2015
    Copy the full SHA
    df012fa View commit details
Showing with 7 additions and 0 deletions.
  1. +2 −0 core/src/main/java/org/jruby/RubyFixnum.java
  2. +5 −0 spec/ruby/core/enumerable/find_index_spec.rb
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -269,6 +269,8 @@ public boolean equals(Object other) {
if (num.value == value) {
return true;
}
} else if (other instanceof RubyFloat) {
return (double)value == ((RubyFloat) other).getDoubleValue();
}

return false;
5 changes: 5 additions & 0 deletions spec/ruby/core/enumerable/find_index_spec.rb
Original file line number Diff line number Diff line change
@@ -48,6 +48,11 @@
@numerous.find_index.should be_an_instance_of(enumerator_class)
end

it "uses #== for testing equality" do
[2].to_enum.find_index(2.0).should == 0
[2.0].to_enum.find_index(2).should == 0
end

describe "without block" do
it "gathers whole arrays as elements when each yields multiple" do
@yieldsmixed.find_index([0, 1, 2]).should == 3