From d604e809667182e6a3cc8f4d5456f18f01bed625 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Fri, 4 Aug 2023 11:17:58 +0100 Subject: [PATCH] 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 00000000..b2d5a56c --- /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 00000000..6a481248 --- /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") + + + + +