-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathlocations.py
More file actions
100 lines (82 loc) · 2.24 KB
/
locations.py
File metadata and controls
100 lines (82 loc) · 2.24 KB
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
import re
# This file contains tests for the regexp parser's location tracking.
# To keep the expected results manageable, we only test the locations of the
# regexp term `[this]`, appearing in various kinds of regexps.
#
# To make the location information easier to understand, we generally put each
# regexp on its own line, even though this is not idiomatic Python.
# Comments indicate the found locations relative to the call to `compile`.
# plain string
re.compile( # $ location=1:2
'[this] is a test'
)
# raw string
re.compile( # $ location=1:3
r'[this] is a test'
)
# byte string
re.compile( # $ location=1:3
b'[this] is a test'
)
# byte raw string
re.compile( # $ location=1:4
br'[this] is a test'
)
# multiline string
re.compile( # $ location=1:4
'''[this] is a test'''
)
# multiline raw string
re.compile( # $ location=1:5
r'''[this] is a test'''
)
# multiline byte string
re.compile( # $ location=1:5
b'''[this] is a test'''
)
# multiline byte raw string
re.compile( # $ location=1:6
br'''[this] is a test'''
)
# plain string with multiple parts
re.compile( # $ location=1:2 location=1:26
'[this] is a test' ' and [this] is another test'
)
# plain string with multiple parts across lines
re.compile( # $ location=1:2 location=2:7 location=3:2
'[this] is a test'
' and [this] is another test'
'[this] comes right at the start of a part'
)
# plain string with multiple parts across lines and comments
re.compile( # $ location=1:2 location=3:7
'[this] is a test'
# comment
' and [this] is another test'
)
# multiple parts of different kinds
re.compile( # $ location=1:2 location=1:28 location=2:11 location=3:8
'[this] is a test' ''' and [this] is another test'''
br""" and [this] is yet another test"""
r' and [this] is one more'
)
# actual multiline string
re.compile( # $ SPURIOUS:location=1:6 location=1:27 MISSING:location=2:1 location=3:5
r'''
[this] is a test
and [this] is another test
'''
)
# plain string with escape sequences
re.compile( # $ SPURIOUS:location=1:3 MISSING:location=1:4
'\t[this] is a test'
)
# raw string with escape sequences
re.compile( # $ location=1:5
r'\A[this] is a test'
)
# plain string with escaped newline
re.compile( # $ location=1:2 SPURIOUS:location=1:23 MISSING:location=2:6
'[this] is a test\
and [this] is another test'
)