From 6dc01f74431a40dac698417d2947f0d8ddbd8c8c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 28 Oct 2024 12:52:11 +0200 Subject: Make $regex.*search() functions not to match empty substrings in non empty strings --- tests/function/regex/testscript | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tests/function/regex') diff --git a/tests/function/regex/testscript b/tests/function/regex/testscript index 538bdab..7fbcc8e 100644 --- a/tests/function/regex/testscript +++ b/tests/function/regex/testscript @@ -366,6 +366,33 @@ EOI } } + + : empty-substring + : + : Note that regex_search() ignores the match_not_null flag for older + : versions of libstdc++ and libc++. + : + if (($cxx.id != 'gcc' || $cxx.version.major >= 7) && \ + ($cxx.id != 'clang' || $cxx.version.major >= 6)) + { + : empty + : + $* <'true' + print $regex.search('', '.*') + EOI + + : match + : + $* <'true' + print $regex.search('a', 'a*') + EOI + + : no-match + : + $* <'false' + print $regex.search('aa', 'b*') + EOI + } } : split @@ -576,6 +603,33 @@ print $regex.find_search(Foo.cxx, 'f', icase) EOI } + + : empty-substring + : + : Note that regex_search() ignores the match_not_null flag for older + : versions of libstdc++ and libc++. + : + if (($cxx.id != 'gcc' || $cxx.version.major >= 7) && \ + ($cxx.id != 'clang' || $cxx.version.major >= 6)) + { + : empty + : + $* <'true' + print $regex.find_search('', '.*') + EOI + + : match + : + $* <'true' + print $regex.find_search('a', 'a*') + EOI + + : no-match + : + $* <'false' + print $regex.find_search('aa', 'b*') + EOI + } } : filter-search @@ -607,6 +661,33 @@ $* <'' print $regex.filter_search(-g, '-O') EOI + + : empty-substring + : + : Note that regex_search() ignores the match_not_null flag for older + : versions of libstdc++ and libc++. + : + if (($cxx.id != 'gcc' || $cxx.version.major >= 7) && \ + ($cxx.id != 'clang' || $cxx.version.major >= 6)) + { + : empty + : + $* <'{}' + print $regex.filter_search('', '.*') + EOI + + : match + : + $* <'a' + print $regex.filter_search('a', 'a*') + EOI + + : no-match + : + $* <'' + print $regex.filter_search('aa', 'b*') + EOI + } } : filter-out -- cgit v1.1