Skip to content

Unexpected behaviour of Enumerator#find_index with block (1.9 mode and HEAD) #525

@kyrylo

Description

@kyrylo

Please, note that Enumerable#find_index on its own works fine. The problem is with Enumerator.

✗ JRUBY_OPTS=--1.9
. .
JRUBY_VERSION 1.7.2
JRUBY_REVISION 302c706
RUBY_VERSION 1.9.3
ENV_JAVA['jruby.enumerator.lightweight'] nil
enum = Enumerator.new { |y| y.yield :fail }
#=> #<Enumerator: ...>
enum.to_a
#=> [:fail]
enum.find_index
#=> #<Enumerator: ...>
enum.find_index(:fail)
#=> 0
enum.find_index { |e| e }
#=> nil
enum.to_a.find_index { |e| e }
#=> 0
✓ JRUBY_OPTS=--1.8
. .
JRUBY_VERSION 1.7.2
JRUBY_REVISION 302c706
RUBY_VERSION 1.8.7
ENV_JAVA['jruby.enumerator.lightweight'] nil
require 'generator'
#=> true
enum = Generator.new { |y| y.yield :success }
#=> #<JRuby::Generator::Threaded: ...>
enum.to_a
#=> [:success]
enum.find_index
#=> #<Enumerable::Enumerator: ...>
enum.find_index(:success)
#=> 0
enum.find_index { |e| e }
#=> 0
✓ MRI 1.9.3
. .
RUBY_VERSION 1.9.3
RUBY_REVISION 38858
enum = Enumerator.new { |y| y.yield :success }
#=> #<Enumerator: ...>
enum.to_a
#=> [:success]
enum.find_index
#=> #<Enumerator: ...>
enum.find_index(:success)
#=> 0
enum.find_index { |e| e }
#=> 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions