Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…argument count

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@2371 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit bd851bce1bc725dc2c1084a0842dfd0fa37907ee 1 parent 131e266
@olabini olabini authored
Showing with 7 additions and 2 deletions.
  1. +2 −1  src/org/jruby/RubyEnumerable.java
  2. +5 −1 test/testEnumerable.rb
View
3  src/org/jruby/RubyEnumerable.java
@@ -170,6 +170,7 @@ public IRubyObject method2(ThreadContext tc, IRubyObject self, IRubyObject[] arg
}
public IRubyObject method3(ThreadContext tc, IRubyObject self, IRubyObject[] args) {
//GREP
+ self.checkArgumentCount(args,1,1);
List arr = eachToList(tc,self,module);
List result = new ArrayList();
IRubyObject pattern = args[0];
@@ -511,4 +512,4 @@ public static RubyModule createEnumerableModule(IRuby runtime) {
return enm;
}
-}
+}
View
6 test/testEnumerable.rb
@@ -67,4 +67,8 @@
b = [ 7, 8, 9 ]
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([[1], [2], [3]],(1..3).zip)
+test_equal([[1], [2], [3]],(1..3).zip)
+
+test_exception(ArgumentError) {
+ ['a'].grep {/foo/}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.