From d604e809667182e6a3cc8f4d5456f18f01bed625 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Fri, 4 Aug 2023 11:17:58 +0100 Subject: [PATCH 1/3] Add tests for 'matches' function --- .../1111-feel-matches-function-test-01.xml | 407 ++++++++++++++++++ .../1111-feel-matches-function.dmn | 363 ++++++++++++++++ 2 files changed, 770 insertions(+) create mode 100644 TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml create mode 100644 TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn diff --git a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml new file mode 100644 index 000000000..b2d5a56cb --- /dev/null +++ b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml @@ -0,0 +1,407 @@ + + + + 1111-feel-matches-function.dmn + + + + + + + + + Evaluates "matches" function with null input + + + + + + + + + Evaluates "matches" function with null pattern + + + + + + + + + Evaluates "matches" function with null flags + + + true + + + + + + Evaluates The "matches" function with the arguments set as follows: $input = xs:string(lower bound) + $pattern = xs:string(lower bound) + + + + true + + + + + + Invalid flag for third argument of matches. + + + + + + + + + Check for the correct behavior of ^ and $ in multi-line mode This test case was motivated by the + resolution of Bug Report 4543 + + + + true + + + + + + Check for the correct behavior of ^ and $ in multi-line mode This test case was motivated by the + resolution of Bug Report 4543 + + + + true + + + + + + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) + + + false + + + + + + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) + + + true + + + + + + Evaluation of matches function with "q" and "i" flags (allowed in XQuery 3.0) + + + true + + + + + + "." does NOT match CR in default mode + + + false + + + + + + Simple call of matches() with "i" flag + + + true + + + + + + Call of matches() with "i" flag and a character range + + + true + + + + + + Call of matches() with "i" flag and a character range + + + true + + + + + + Call of matches() with "i" flag and Kelvin sign Kelvin sign + + + true + + + + + + Call of matches() with "i" flag and range subtraction + + + true + + + + + + Call of matches() with "i" flag and range subtraction + + + true + + + + + + Call of matches() with "i" flag and range subtraction + + + false + + + + + + Call of matches() with "i" flag and range subtraction + + + false + + + + + + Call of matches() with "i" flag and negation + + + false + + + + + + Call of matches() with "i" flag and negation + + + false + + + + + + The pattern can't be the empty sequence. + + + + + + + + + matches() takes at least two arguments, not one. + + + + + + + + + The third argument cannot be the empty sequence. + + + + + + + + + Only three arguments are accepted. + + + + + + + + + The flags argument cannot contain whitespace. + + + + + + + + + The flags argument cannot contain 'X'. + + + + + + + + + Whitespace in the regexp is collapsed. + + + true + + + + + + Whitespace(before) in the regexp is collapsed, but not inside a character class. + + + true + + + + + + Whitespace(after) in the regexp is collapsed, but not inside a character class. + + + true + + + + + + Whitespace(in the middle) in the regexp is collapsed, but not inside a character class. + + + + true + + + + + + whitespace in the regexp is collapsed, and should therefore compile. + + + true + + + + + + whitespace in the regexp is collapsed completely, and should therefore compile and match. + + + + true + + + + + + whitespace in the regexp is not collapsed, and should therefore not compile. + + + + + + + + + Since no string is captured by the back-reference, the single character is matched. + + + + + + + + + Since no string is captured by the back-reference, the single character is matched(#2). + + + + + + + + + + A non-matching backwards-reference matches the empty string. + + + + + + + + + Use a back reference inside a character class. + + + + + + + + + Use a back reference inside a character class(#2). + + + + + + + + + Use a back reference inside a character class(#3). + + + + + + + + + Use a back reference inside a character class(#3). + + + + + + + + + Use a pattern whose interpretation is unknown. See public report 4466 and 21425. + + + false + + + + + + Caseless match with back-reference. + + + true + + + + diff --git a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn new file mode 100644 index 000000000..6a4812481 --- /dev/null +++ b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn @@ -0,0 +1,363 @@ + + + + FEEL built-in function 'matches(input, pattern, flags?)' in category string functions + + + Evaluates "matches" function with null input + + + matches(null, "pattern") + + + + + Evaluates "matches" function with null pattern + + + matches("input", null) + + + + + Evaluates "matches" function with null flags + + + matches("abracadabra", "bra", null) + + + + + Evaluates "matches" function with the arguments set as follows: $input = xs:string(lower bound) $pattern = xs:string(lower bound) + + + matches("This is a characte","This is a characte") + + + + + Invalid flag for third argument of matches. + + + matches("abracadabra", "bra", "p") + + + + + Check for the correct behavior of ^ and $ in multi-line mode This test case was motivated by the resolution of Bug Report 4543 + + + matches("\nabcd\ndefg\n", "^$", "m") + + + + + Check for the correct behavior of ^ and $ in multi-line mode This test case was motivated by the resolution of Bug Report 4543 + + + matches("abcd\n\ndefg\n ", "^$", "m") + + + + + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) + + + matches("abracadabra", "(?:abra(?:cad)?)*", "q") + + + + + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) + + + matches("x[y-z]", "x[y-z]", "q") + + + + + Evaluation of matches function with "q" and "i" flags (allowed in XQuery 3.0) + + + matches("x[Y-z]", "X[y-Z]", "qi") + + + + + "." does NOT match CR in default mode + + + matches("Mary\u000DJones", "Mary.Jones") + + + + + Simple call of matches() with "i" flag + + + matches("abc", "ABC", "i") + + + + + Call of matches() with "i" flag and a character range + + + matches("abZ", "[A-Z]*", "i") + + + + + Call of matches() with "i" flag and a character range + + + matches("abZ", "[a-z]*", "i") + + + + + Call of matches() with "i" flag and Kelvin sign Kelvin sign + + + matches("\u212A", "k", "i") + + + + + Call of matches() with "i" flag and range subtraction + + + matches("x", "[A-Z-[OI]]", "i") + + + + + Call of matches() with "i" flag and range subtraction + + + matches("X", "[A-Z-[OI]]", "i") + + + + + Call of matches() with "i" flag and range subtraction + + + matches("O", "[A-Z-[OI]]", "i") + + + + + Call of matches() with "i" flag and range subtraction + + + matches("i", "[A-Z-[OI]]", "i") + + + + + Call of matches() with "i" flag and negation + + + matches("Q", "[^Q]", "i") + + + + + Call of matches() with "i" flag and negation + + + matches("q", "[^Q]", "i") + + + + + The pattern can't be the empty sequence. + + + matches("input", []) + + + + + matches() takes at least two arguments, not one. + + + matches("input") + + + + + The third argument cannot be the empty sequence. + + + matches("input", "pattern", []) + + + + + Only three arguments are accepted. + + + matches("input", "pattern", "", []) + + + + + The flags argument cannot contain whitespace. + + + matches("input", "pattern", " ") + + + + + The flags argument cannot contain 'X'. + + + matches("input", "pattern", "X") + + + + + Whitespace in the regexp is collapsed. + + + matches("hello world", "hello\ sworld", "x") + + + + + Whitespace(before) in the regexp is collapsed, but not inside a character class. + + + matches("hello world", " hello[ ]world", "x") + + + + + Whitespace(after) in the regexp is collapsed, but not inside a character class. + + + matches("hello world", "hello[ ]world ", "x") + + + + + Whitespace(in the middle) in the regexp is collapsed, but not inside a character class. + + + matches("hello world", "he ll o[ ]worl d", "x") + + + + + whitespace in the regexp is collapsed, and should therefore compile. + + + matches("hello world", "\p{ IsBasicLatin}+", "x") + + + + + whitespace in the regexp is collapsed completely, and should therefore compile and match. + + + matches("hello world", "\p{ I s B a s i c L a t i n }+", "x") + + + + + whitespace in the regexp is not collapsed, and should therefore not compile. + + + matches("hello world", "\p{ IsBasicLatin}+") + + + + + Since no string is captured by the back-reference, the single character is matched. + + + matches("h", "(.)\3") + + + + + Since no string is captured by the back-reference, the single character is matched(#2). + + + matches("h", "(.)\2") + + + + + A non-matching backwards-reference matches the empty string. + + + matches("input", "\3") + + + + + Use a back reference inside a character class. + + + matches("abcd", "(asd)[\1]") + + + + + Use a back reference inside a character class(#2). + + + matches("abcd", "(asd)[asd\1]") + + + + + Use a back reference inside a character class(#3). + + + matches("abcd", "(asd)[asd\0]") + + + + + Use a back reference inside a character class(#3). + + + matches("abcd", "1[asd\0]") + + + + + A negative character class never match a non-character. + + + matches("a", "a[^b]"), matches("a ", "a[^b]") + + + + + Use a pattern whose interpretation is unknown. See public report 4466 and 21425. + + + matches("input", "[0-9-.]*/") + + + + + Caseless match with back-reference. + + + matches("aA", "(a)\1", "i") + + + + + From 60f63ae9076340c3d326f39d6409930783098591 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Fri, 4 Aug 2023 11:21:56 +0100 Subject: [PATCH 2/3] Removed incorrect attribute --- .../1111-feel-matches-function.dmn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn index 6a4812481..a3db1573d 100644 --- a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn +++ b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn @@ -63,7 +63,7 @@ - + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) @@ -71,7 +71,7 @@ - + Evaluation of matches function with "q" flag (allowed in XQuery 3.0) @@ -79,7 +79,7 @@ - + Evaluation of matches function with "q" and "i" flags (allowed in XQuery 3.0) @@ -87,7 +87,7 @@ - + "." does NOT match CR in default mode From 5209cd44fb7c6d8d1b25f74700b8213641b3e2e7 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Thu, 2 Nov 2023 14:28:50 +0000 Subject: [PATCH 3/3] Add tests for 'matches' function. Address comments in PR --- .../1111-feel-matches-function-test-01.xml | 28 ++++++++++++++++--- .../1111-feel-matches-function.dmn | 12 ++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml index b2d5a56cb..b6775fff0 100644 --- a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml +++ b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function-test-01.xml @@ -78,6 +78,7 @@ + "." does NOT match CR in default mode @@ -387,15 +389,33 @@ - - Use a pattern whose interpretation is unknown. See public report 4466 and 21425. - + + A negative character class never match a non-character. + - false + + + false + + + true + + + + Caseless match with back-reference. diff --git a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn index a3db1573d..21e55264c 100644 --- a/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn +++ b/TestCases/compliance-level-3/1111-feel-matches-function/1111-feel-matches-function.dmn @@ -1,12 +1,16 @@ - FEEL built-in function 'matches(input, pattern, flags?)' in category string functions + + boolean + + Evaluates "matches" function with null input @@ -63,6 +67,7 @@ + "." does NOT match CR in default mode @@ -337,9 +343,9 @@ A negative character class never match a non-character. - + - matches("a", "a[^b]"), matches("a ", "a[^b]") + [matches("a", "a[^b]"), matches("a ", "a[^b]")]