Skip to content
Permalink
Browse files

Merge pull request #823 from danshultz/string_chomp_passed_nil

string.chomp!(nil) returns nil
  • Loading branch information
alex committed Oct 13, 2013
2 parents c924603 + 8a05048 commit dce3eef7b1910fc5600a4cd0afd6220543104823
Showing with 3 additions and 3 deletions.
  1. +0 −2 spec/tags/core/string/chomp_tags.txt
  2. +2 −0 tests/objects/test_stringobject.py
  3. +1 −1 topaz/objects/stringobject.py
@@ -1,4 +1,2 @@
fails:String#chomp! when passed nil returns nil
fails:String#chomp! when passed nil returns nil when self is empty
fails:String#chomp removes the final carriage return, newline from a non-ASCII String
fails:String#chomp! removes the final carriage return, newline from a non-ASCII String
@@ -440,6 +440,8 @@ def test_chomp(self, space):
assert w_res is space.w_nil
w_res = space.execute('return "".chomp!')
assert w_res is space.w_nil
w_res = space.execute('return "abc".chomp!(nil)')
assert w_res is space.w_nil
w_res = space.execute('return "abc\\r".chomp!("")')
assert w_res is space.w_nil

@@ -1212,7 +1212,7 @@ def method_chomp_i(self, space, w_newline=None):
if w_newline is None:
w_newline = space.globals.get(space, "$/")
if w_newline is space.w_nil:
return self
return space.w_nil
newline = space.str_w(space.convert_type(w_newline, space.w_string, "to_str"))
if newline and newline in "\n\r":
newline = None

0 comments on commit dce3eef

Please sign in to comment.