Skip to content

Commit

Permalink
Test I-Regexp mapping corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed May 11, 2024
1 parent 7c8e9bc commit 6c5b0be
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/functions/match.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,48 @@
"a": "ab"
}
]
},
{
"name": "dot in character class",
"selector" : "$[?match(@, 'a[.b]c')]",
"document" : ["abc", "a.c", "axc"],
"result": ["abc", "a.c"]
},
{
"name": "escaped dot",
"selector" : "$[?match(@, 'a\\\\.c')]",
"document" : ["abc", "a.c", "axc"],
"result": ["a.c"]
},
{
"name": "escaped backslash before dot",
"selector" : "$[?match(@, 'a\\\\\\\\.c')]",
"document" : ["abc", "a.c", "axc", "a\\\u2028c"],
"result": ["a\\\u2028c"]
},
{
"name": "escaped left square bracket",
"selector" : "$[?match(@, 'a\\\\[.c')]",
"document" : ["abc", "a.c", "a[\u2028c"],
"result": ["a[\u2028c"]
},
{
"name": "escaped right square bracket",
"selector" : "$[?match(@, 'a[\\\\].]c')]",
"document" : ["abc", "a.c", "a\u2028c", "a]c"],
"result": ["a.c", "a]c"]
},
{
"name": "explicit caret",
"selector" : "$[?match(@, '^ab.*')]",
"document" : ["abc", "axc", "ab", "xab"],
"result": ["abc", "ab"]
},
{
"name": "explicit dollar",
"selector" : "$[?match(@, '.*bc$')]",
"document" : ["abc", "axc", "ab", "abcx"],
"result": ["abc"]
}
]
}
30 changes: 30 additions & 0 deletions tests/functions/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@
]
},
"result": ["bab", "bba", "bbab"]
},
{
"name": "dot in character class",
"selector" : "$[?search(@, 'a[.b]c')]",
"document" : ["x abc y", "x a.c y", "x axc y"],
"result": ["x abc y", "x a.c y"]
},
{
"name": "escaped dot",
"selector" : "$[?search(@, 'a\\\\.c')]",
"document" : ["x abc y", "x a.c y", "x axc y"],
"result": ["x a.c y"]
},
{
"name": "escaped backslash before dot",
"selector" : "$[?search(@, 'a\\\\\\\\.c')]",
"document" : ["x abc y", "x a.c y", "x axc y", "x a\\\u2028c y"],
"result": ["x a\\\u2028c y"]
},
{
"name": "escaped left square bracket",
"selector" : "$[?search(@, 'a\\\\[.c')]",
"document" : ["x abc y", "x a.c y", "x a[\u2028c y"],
"result": ["x a[\u2028c y"]
},
{
"name": "escaped right square bracket",
"selector" : "$[?search(@, 'a[\\\\].]c')]",
"document" : ["x abc y", "x a.c y", "x a\u2028c y", "x a]c y"],
"result": ["x a.c y", "x a]c y"]
}
]
}

0 comments on commit 6c5b0be

Please sign in to comment.