MatchData#select bug
--------------------

                 Key: JRUBY-3045
                 URL: http://jira.codehaus.org/browse/JRUBY-3045
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
         Environment: OS X, jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-10-04 
rev 7830) [i386-java]
            Reporter: Daniel Berger
             Fix For: JRuby 1.1.5


Looks like MatchData#select is busted. Below are the tests I'm using:

{noformat}
class TC_MatchData_Select_InstanceMethod < Test::Unit::TestCase
   def setup
      @string = 'THX1138'
      @regex  = /(.)(.)(\d+)(\d)/
      @nested = /(\d(\w(\w)\w)\d)/
      @plain  = /\w+/
      @match  = @regex.match(@string)
   end

   def test_select_basic
      assert_respond_to(@match, :select)
      assert_nothing_raised{ @match.select{} }
      assert_kind_of(Array, @match.select{})
   end

   def test_select
      assert_equal(['HX1138', '113', '8'], @match.select{ |x| x =~ /\d/ })
      assert_equal(['1abc2', '1abc2'], @nested.match('1abc2').select{ |x| x =~ 
/\d/ })
      assert_equal([], @plain.match('hello').select{ |x| x =~ /\d/ })
   end

   def test_select_expected_errors
      assert_raise(ArgumentError){ @match.select(1) }
      assert_raise(LocalJumpError){ @match.select }
   end

   def teardown
      @string = nil
      @regex  = nil
      @nested = nil
      @plain  = nil
      @match  = nil
   end
end
{noformat}

Here are the failures with JRuby:

{noformat}
4) Failure:
test_select(TC_MatchData_Select_InstanceMethod) 
[/Users/djberge/Documents/workspace/ruby_test/./test/core/MatchData/instance/tc_select.rb:24]:
<["HX1138", "113", "8"]> expected but was
<false>.

  5) Failure:
test_select_basic(TC_MatchData_Select_InstanceMethod) 
[/Users/djberge/Documents/workspace/ruby_test/./test/core/MatchData/instance/tc_select.rb:20]:
<nil>
expected to be kind_of?
<Array> but was
<NilClass>.
{noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to