summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorU.Nakamura <usa@ruby-lang.org>2023-07-25 20:00:21 +0900
committerU.Nakamura <usa@ruby-lang.org>2023-07-25 20:00:21 +0900
commit7e926c4d8c2e785d174161b38a8a688b19ea4b99 (patch)
tree8208f088e914b9d47e26a3c57c7deeaf2d6fbffb /test/ruby
parent2698b68ae86df333ff8bc8c4655f8012ee619257 (diff)
String#slice! should clear the coderange when truncating
[Bug #19739] This bug was incidentally fixed in Ruby 3.2 via b0b9f72 but remains on 3.1 and older. this patch is written by byroot, https://github.com/Shopify/ruby/commit/3b351ee62d4206bb72301c2e98dcb173f1e35be7 Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_string.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 3f7c06e075..6c00aa15f9 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -3232,6 +3232,12 @@ CODE
assert_not_predicate(data, :valid_encoding?)
assert_predicate(data[100..-1], :valid_encoding?)
end
+
+ def test_slice_bang_code_range
+ str = "[Bug #19739] ABC OÜ"
+ str.slice!(/ oü$/i)
+ assert_predicate str, :ascii_only?
+ end
end
class TestString2 < TestString