1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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.
[[]]
= "basic"
= '(?mR)^[a-z]+$'
= "abc\r\ndef\r\nxyz"
= [[0, 3], [5, 8], [10, 13]]
# Tests that a CRLF-aware '^$' assertion does not match between CR and LF.
[[]]
= "start-end-non-empty"
= '(?mR)^$'
= "abc\r\ndef\r\nxyz"
= []
# Tests that a CRLF-aware '^$' assertion matches the empty string, just like
# a non-CRLF-aware '^$' assertion.
[[]]
= "start-end-empty"
= '(?mR)^$'
= ""
= [[0, 0]]
# Tests that a CRLF-aware '^$' assertion matches the empty string preceding
# and following a line terminator.
[[]]
= "start-end-before-after"
= '(?mR)^$'
= "\r\n"
= [[0, 0], [2, 2]]
# Tests that a CRLF-aware '^' assertion does not split a line terminator.
[[]]
= "start-no-split"
= '(?mR)^'
= "abc\r\ndef\r\nxyz"
= [[0, 0], [5, 5], [10, 10]]
# Same as above, but with adjacent runs of line terminators.
[[]]
= "start-no-split-adjacent"
= '(?mR)^'
= "\r\n\r\n\r\n"
= [[0, 0], [2, 2], [4, 4], [6, 6]]
# Same as above, but with adjacent runs of just carriage returns.
[[]]
= "start-no-split-adjacent-cr"
= '(?mR)^'
= "\r\r\r"
= [[0, 0], [1, 1], [2, 2], [3, 3]]
# Same as above, but with adjacent runs of just line feeds.
[[]]
= "start-no-split-adjacent-lf"
= '(?mR)^'
= "\n\n\n"
= [[0, 0], [1, 1], [2, 2], [3, 3]]
# Tests that a CRLF-aware '$' assertion does not split a line terminator.
[[]]
= "end-no-split"
= '(?mR)$'
= "abc\r\ndef\r\nxyz"
= [[3, 3], [8, 8], [13, 13]]
# Same as above, but with adjacent runs of line terminators.
[[]]
= "end-no-split-adjacent"
= '(?mR)$'
= "\r\n\r\n\r\n"
= [[0, 0], [2, 2], [4, 4], [6, 6]]
# Same as above, but with adjacent runs of just carriage returns.
[[]]
= "end-no-split-adjacent-cr"
= '(?mR)$'
= "\r\r\r"
= [[0, 0], [1, 1], [2, 2], [3, 3]]
# Same as above, but with adjacent runs of just line feeds.
[[]]
= "end-no-split-adjacent-lf"
= '(?mR)$'
= "\n\n\n"
= [[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.
[[]]
= "dot-no-crlf"
= '(?R).'
= "\r\n\r\n\r\n"
= []
# 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.
[[]]
= "onepass-wrong-crlf-with-capture"
= '(?Rm:().$)'
= "ZZ\r"
= [[[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.)
[[]]
= "onepass-wrong-crlf-anchored"
= '(?Rm:.$)'
= "ZZ\r"
= [[1, 2]]
= true
= [1, 3]