Skip to content
This repository
Browse code

Fix for JRUBY-208 (ArrayIndexOutOfBoundsException on grep with wrong …

…argument count

git-svn-id: http://svn.codehaus.org/jruby/trunk@2371 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit b3a9de6bf1a4e86de588840568bacab0960d7dba 1 parent cf92820
Ola Bini olabini authored
3  jruby/src/org/jruby/RubyEnumerable.java
@@ -170,6 +170,7 @@ public IRubyObject method2(ThreadContext tc, IRubyObject self, IRubyObject[] arg
170 170 }
171 171 public IRubyObject method3(ThreadContext tc, IRubyObject self, IRubyObject[] args) {
172 172 //GREP
  173 + self.checkArgumentCount(args,1,1);
173 174 List arr = eachToList(tc,self,module);
174 175 List result = new ArrayList();
175 176 IRubyObject pattern = args[0];
@@ -511,4 +512,4 @@ public static RubyModule createEnumerableModule(IRuby runtime) {
511 512
512 513 return enm;
513 514 }
514   -}
  515 +}
6 jruby/test/testEnumerable.rb
@@ -67,4 +67,8 @@
67 67 b = [ 7, 8, 9 ]
68 68 test_equal([[1, 4, 7], [2, 5, 8], [3, 6, 9]],(1..3).zip(a, b))
69 69 test_equal([["cat\n", 1], ["dog", nil]],"cat\ndog".zip([1]))
70   -test_equal([[1], [2], [3]],(1..3).zip)
  70 +test_equal([[1], [2], [3]],(1..3).zip)
  71 +
  72 +test_exception(ArgumentError) {
  73 + ['a'].grep {/foo/}
  74 +}

0 comments on commit b3a9de6

Please sign in to comment.
Something went wrong with that request. Please try again.