Debian Codegraph @

third_party/rust/regex/testdata/line-terminator.toml

raw
1 # This tests that we can switch the line terminator to the NUL byte.
2 [[test]]
3 name = "nul"
4 regex = '(?m)^[a-z]+$'
5 haystack = '\x00abc\x00'
6 matches = [[1, 4]]
7 unescape = true
8 line-terminator = '\x00'
9
10 # This tests that '.' will not match the configured line terminator, but will
11 # match \n.
12 [[test]]
13 name = "dot-changes-with-line-terminator"
14 regex = '.'
15 haystack = '\x00\n'
16 matches = [[1, 2]]
17 unescape = true
18 line-terminator = '\x00'
19
20 # This tests that when we switch the line terminator, \n is no longer
21 # recognized as the terminator.
22 [[test]]
23 name = "not-line-feed"
24 regex = '(?m)^[a-z]+$'
25 haystack = '\nabc\n'
26 matches = []
27 unescape = true
28 line-terminator = '\x00'
29
30 # This tests that we can set the line terminator to a non-ASCII byte and have
31 # it behave as expected.
32 [[test]]
33 name = "non-ascii"
34 regex = '(?m)^[a-z]+$'
35 haystack = '\xFFabc\xFF'
36 matches = [[1, 4]]
37 unescape = true
38 line-terminator = '\xFF'
39 utf8 = false
40
41 # This tests that we can set the line terminator to a byte corresponding to a
42 # word character, and things work as expected.
43 [[test]]
44 name = "word-byte"
45 regex = '(?m)^[a-z]+$'
46 haystack = 'ZabcZ'
47 matches = [[1, 4]]
48 unescape = true
49 line-terminator = 'Z'
50
51 # This tests that we can set the line terminator to a byte corresponding to a
52 # non-word character, and things work as expected.
53 [[test]]
54 name = "non-word-byte"
55 regex = '(?m)^[a-z]+$'
56 haystack = '%abc%'
57 matches = [[1, 4]]
58 unescape = true
59 line-terminator = '%'
60
61 # This combines "set line terminator to a word byte" with a word boundary
62 # assertion, which should result in no match even though ^/$ matches.
63 [[test]]
64 name = "word-boundary"
65 regex = '(?m)^\b[a-z]+\b$'
66 haystack = 'ZabcZ'
67 matches = []
68 unescape = true
69 line-terminator = 'Z'
70
71 # Like 'word-boundary', but does an anchored search at the point where ^
72 # matches, but where \b should not.
73 [[test]]
74 name = "word-boundary-at"
75 regex = '(?m)^\b[a-z]+\b$'
76 haystack = 'ZabcZ'
77 matches = []
78 bounds = [1, 4]
79 anchored = true
80 unescape = true
81 line-terminator = 'Z'
82
83 # Like 'word-boundary-at', but flips the word boundary to a negation. This
84 # in particular tests a tricky case in DFA engines, where they must consider
85 # explicitly that a starting configuration from a custom line terminator may
86 # also required setting the "is from word byte" flag on a state. Otherwise,
87 # it's treated as "not from a word byte," which would result in \B not matching
88 # here when it should.
89 [[test]]
90 name = "not-word-boundary-at"
91 regex = '(?m)^\B[a-z]+\B$'
92 haystack = 'ZabcZ'
93 matches = [[1, 4]]
94 bounds = [1, 4]
95 anchored = true
96 unescape = true
97 line-terminator = 'Z'