From de64d2d836fcbf13e71be29d73684374170da8aa Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 9 Sep 2023 08:55:20 +1000 Subject: expr: add support for =* and =~ glob match and regexp match operators Signed-off-by: Steve Bennett --- tests/regexp2.test | 16 ++++++++++++++++ tests/stringmatch.test | 12 ++++++++++++ 2 files changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/regexp2.test b/tests/regexp2.test index 571c981..c3db17d 100644 --- a/tests/regexp2.test +++ b/tests/regexp2.test @@ -943,4 +943,20 @@ test regexp-25.3 {End of word} { regexp {\mcd\M} cdef } 0 +test regexp-26.1 {regexp operator =~} { + expr {"abc" =~ "^a"} +} 1 + +test regexp-26.2 {regexp operator =~} { + expr {"abc" =~ "^b"} +} 0 + +test regexp-26.2 {regexp operator =~} { + expr {"abc" =~ ".b."} +} 1 + +test regexp-26.3 {regexp operator =~ invalid regexp} -body { + expr {"abc" =~ {[}} +} -returnCodes error -result {couldn't compile regular expression pattern: brackets [] not balanced} + testreport diff --git a/tests/stringmatch.test b/tests/stringmatch.test index f0eab2a..c15acd1 100644 --- a/tests/stringmatch.test +++ b/tests/stringmatch.test @@ -230,4 +230,16 @@ test stringmatch-7.4 {null in pattern} { string match *b\[\0a\]r* foobar } 1 +test stringmatch-8.1 {string match operator =*} { + expr {"abc" =* "a*"} +} 1 + +test stringmatch-8.2 {string match operator =*} { + expr {"abc" =* "b*"} +} 0 + +test stringmatch-8.3 {string match operator =*} { + expr {"abc" =* {*[bB]c}} +} 1 + testreport -- cgit v1.1