summaryrefslogtreecommitdiffstats
path: root/vendor/regex/testdata/crlf.toml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/regex/testdata/crlf.toml
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/regex/testdata/crlf.toml')
-rw-r--r--vendor/regex/testdata/crlf.toml117
1 files changed, 117 insertions, 0 deletions
diff --git a/vendor/regex/testdata/crlf.toml b/vendor/regex/testdata/crlf.toml
new file mode 100644
index 000000000..9e2d3761a
--- /dev/null
+++ b/vendor/regex/testdata/crlf.toml
@@ -0,0 +1,117 @@
+# This is a basic test that checks ^ and $ treat \r\n as a single line
+# terminator. If ^ and $ only treated \n as a line terminator, then this would
+# only match 'xyz' at the end of the haystack.
+[[test]]
+name = "basic"
+regex = '(?mR)^[a-z]+$'
+haystack = "abc\r\ndef\r\nxyz"
+matches = [[0, 3], [5, 8], [10, 13]]
+
+# Tests that a CRLF-aware '^$' assertion does not match between CR and LF.
+[[test]]
+name = "start-end-non-empty"
+regex = '(?mR)^$'
+haystack = "abc\r\ndef\r\nxyz"
+matches = []
+
+# Tests that a CRLF-aware '^$' assertion matches the empty string, just like
+# a non-CRLF-aware '^$' assertion.
+[[test]]
+name = "start-end-empty"
+regex = '(?mR)^$'
+haystack = ""
+matches = [[0, 0]]
+
+# Tests that a CRLF-aware '^$' assertion matches the empty string preceding
+# and following a line terminator.
+[[test]]
+name = "start-end-before-after"
+regex = '(?mR)^$'
+haystack = "\r\n"
+matches = [[0, 0], [2, 2]]
+
+# Tests that a CRLF-aware '^' assertion does not split a line terminator.
+[[test]]
+name = "start-no-split"
+regex = '(?mR)^'
+haystack = "abc\r\ndef\r\nxyz"
+matches = [[0, 0], [5, 5], [10, 10]]
+
+# Same as above, but with adjacent runs of line terminators.
+[[test]]
+name = "start-no-split-adjacent"
+regex = '(?mR)^'
+haystack = "\r\n\r\n\r\n"
+matches = [[0, 0], [2, 2], [4, 4], [6, 6]]
+
+# Same as above, but with adjacent runs of just carriage returns.
+[[test]]
+name = "start-no-split-adjacent-cr"
+regex = '(?mR)^'
+haystack = "\r\r\r"
+matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
+
+# Same as above, but with adjacent runs of just line feeds.
+[[test]]
+name = "start-no-split-adjacent-lf"
+regex = '(?mR)^'
+haystack = "\n\n\n"
+matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
+
+# Tests that a CRLF-aware '$' assertion does not split a line terminator.
+[[test]]
+name = "end-no-split"
+regex = '(?mR)$'
+haystack = "abc\r\ndef\r\nxyz"
+matches = [[3, 3], [8, 8], [13, 13]]
+
+# Same as above, but with adjacent runs of line terminators.
+[[test]]
+name = "end-no-split-adjacent"
+regex = '(?mR)$'
+haystack = "\r\n\r\n\r\n"
+matches = [[0, 0], [2, 2], [4, 4], [6, 6]]
+
+# Same as above, but with adjacent runs of just carriage returns.
+[[test]]
+name = "end-no-split-adjacent-cr"
+regex = '(?mR)$'
+haystack = "\r\r\r"
+matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
+
+# Same as above, but with adjacent runs of just line feeds.
+[[test]]
+name = "end-no-split-adjacent-lf"
+regex = '(?mR)$'
+haystack = "\n\n\n"
+matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
+
+# Tests that '.' does not match either \r or \n when CRLF mode is enabled. Note
+# that this doesn't require multi-line mode to be enabled.
+[[test]]
+name = "dot-no-crlf"
+regex = '(?R).'
+haystack = "\r\n\r\n\r\n"
+matches = []
+
+# This is a test that caught a bug in the one-pass DFA where it (amazingly) was
+# using 'is_end_lf' instead of 'is_end_crlf' here. It was probably a copy &
+# paste bug. We insert an empty capture group here because it provokes the meta
+# regex engine to first find a match and then trip over a panic because the
+# one-pass DFA erroneously says there is no match.
+[[test]]
+name = "onepass-wrong-crlf-with-capture"
+regex = '(?Rm:().$)'
+haystack = "ZZ\r"
+matches = [[[1, 2], [1, 1]]]
+
+# This is like onepass-wrong-crlf-with-capture above, except it sets up the
+# test so that it can be run by the one-pass DFA directly. (i.e., Make it
+# anchored and start the search at the right place.)
+[[test]]
+name = "onepass-wrong-crlf-anchored"
+regex = '(?Rm:.$)'
+haystack = "ZZ\r"
+matches = [[1, 2]]
+anchored = true
+bounds = [1, 3]