Skip to content
Browse files

Merge pull request #852 from kachick/string-sub-without-replacement

String#sub without replacement and block should raise an ArgumentError
  • Loading branch information
alex committed Oct 18, 2015
2 parents d3991e0 + 2d46b04 commit c6aa891465c3fc8cd73f80dd309a850dbcbe47ff
Showing with 4 additions and 0 deletions.
  1. +2 −0 tests/objects/
  2. +2 −0 topaz/objects/
@@ -538,6 +538,8 @@ def test_sub(self, space):
return 'helloo'.sub("l", { |h, k| replacements.pop() })
assert space.str_w(w_res) == "he2loo"
with self.raises(space, "ArgumentError"):

def test_succ(self, space):
w_res = space.execute('return "abcd".succ')
@@ -1080,6 +1080,8 @@ def method_gsub(self, space, w_pattern, w_replacement=None, block=None):

def method_sub(self, space, w_pattern, w_replacement=None, block=None):
if w_replacement is None and block is None:
raise space.error(space.w_ArgumentError, "wrong number of arguments")
return self.gsub_main(space, w_pattern, w_replacement, block, first_only=True)

def gsub_main(self, space, w_pattern, w_replacement, block, first_only):

0 comments on commit c6aa891

Please sign in to comment.
You can’t perform that action at this time.