Skip to content

Commit

Permalink
Fix for JRUBY-208 (ArrayIndexOutOfBoundsException on grep with wrong …
Browse files Browse the repository at this point in the history
…argument count

git-svn-id: http://svn.codehaus.org/jruby/trunk@2371 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
olabini committed Oct 23, 2006
1 parent cf92820 commit b3a9de6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion jruby/src/org/jruby/RubyEnumerable.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public IRubyObject method2(ThreadContext tc, IRubyObject self, IRubyObject[] arg
} }
public IRubyObject method3(ThreadContext tc, IRubyObject self, IRubyObject[] args) { public IRubyObject method3(ThreadContext tc, IRubyObject self, IRubyObject[] args) {
//GREP //GREP
self.checkArgumentCount(args,1,1);
List arr = eachToList(tc,self,module); List arr = eachToList(tc,self,module);
List result = new ArrayList(); List result = new ArrayList();
IRubyObject pattern = args[0]; IRubyObject pattern = args[0];
Expand Down Expand Up @@ -511,4 +512,4 @@ public static RubyModule createEnumerableModule(IRuby runtime) {


return enm; return enm;
} }
} }
6 changes: 5 additions & 1 deletion jruby/test/testEnumerable.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@
b = [ 7, 8, 9 ] b = [ 7, 8, 9 ]
test_equal([[1, 4, 7], [2, 5, 8], [3, 6, 9]],(1..3).zip(a, b)) test_equal([[1, 4, 7], [2, 5, 8], [3, 6, 9]],(1..3).zip(a, b))
test_equal([["cat\n", 1], ["dog", nil]],"cat\ndog".zip([1])) test_equal([["cat\n", 1], ["dog", nil]],"cat\ndog".zip([1]))
test_equal([[1], [2], [3]],(1..3).zip) test_equal([[1], [2], [3]],(1..3).zip)

test_exception(ArgumentError) {
['a'].grep {/foo/}
}

0 comments on commit b3a9de6

Please sign in to comment.