diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-27 21:54:34 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-27 21:54:34 +0900 |
commit | f1b76ea63ce40670071a857f408a4747c571f1e9 (patch) | |
tree | 941d10f573698fca4cefb737bdd09b12e6081128 /test | |
parent | e3b613a66986306950fc69d426d947a349b9fc8b (diff) | |
download | ruby-f1b76ea63ce40670071a857f408a4747c571f1e9.tar.gz |
Occupy match data
* string.c (rb_str_split_m): occupy match data not to be modified
during yielding the block. [Bug #16024]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 611bb797bc..7ae3bf272e 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1779,6 +1779,9 @@ CODE result = []; "".split(//, 1) {|s| result << s} assert_equal([], result) + + result = []; "aaa,bbb,ccc,ddd".split(/,/) {|s| result << s.gsub(/./, "A")} + assert_equal(["AAA"]*4, result) ensure EnvUtil.suppress_warning {$; = fs} end |