aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKasumi Hanazuki <kasumi@rollingapple.net>2020-08-11 09:32:02 +0000
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-12 10:01:39 +0900
commite79cdcf61b0665d8a9bb309a607227de43e95673 (patch)
treecd0ef903162b7ba737a2734a639a962b5f014752 /test
parent66efe373116d510c05d57964b5ffa47f1c6e565c (diff)
downloadruby-e79cdcf61b0665d8a9bb309a607227de43e95673.tar.gz
string.c(rb_str_split_m): Handle /\K/ correctly
Use BEG(0) instead of the result of rb_reg_search to handle the cases when the separator Regexp contains /\K/ (lookbehind) operator. Fixes [Bug #17113]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 89f5b6cf9d..c4c7d55f00 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1838,6 +1838,11 @@ CODE
assert_equal("abc", s)
end
+ def test_split_lookbehind
+ assert_equal([S("ab"), S("d")], S("abcd").split(/(?<=b)c/))
+ assert_equal([S("ab"), S("d")], S("abcd").split(/b\Kc/))
+ end
+
def test_squeeze
assert_equal(S("abc"), S("aaabbbbccc").squeeze)
assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" ")))