Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bd417226
Commit
bd417226
authored
Aug 08, 2000
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-- whitespace cleanup (real changes coming in next checkin)
parent
acaff520
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
Lib/test/re_tests.py
Lib/test/re_tests.py
+20
-20
No files found.
Lib/test/re_tests.py
View file @
bd417226
...
...
@@ -10,21 +10,21 @@
# Benchmark suite (needs expansion)
#
# The benchmark suite does not test correctness, just speed. The
# first element of each tuple is the regex pattern; the second is a
# first element of each tuple is the regex pattern; the second is a
# string to match it against. The benchmarking code will embed the
# second string inside several sizes of padding, to test how regex
# second string inside several sizes of padding, to test how regex
# matching performs on large strings.
benchmarks
=
[
(
'Python'
,
'Python'
),
# Simple text literal
(
'.*Python'
,
'Python'
),
# Bad text literal
(
'.*Python.*'
,
'Python'
),
# Worse text literal
(
'.*(Python)'
,
'Python'
),
# Bad text literal with grouping
(
'(Python|Perl|Tcl'
,
'Perl'
),
# Alternation
(
'(Python|Perl|Tcl)'
,
'Perl'
),
# Grouped alternation
(
'(Python)
\
\
1'
,
'PythonPython'
),
# Backreference
(
'([0a-z][a-z]*,)+'
,
'a5,b7,c9,'
),
# Disable the fastmap optimization
(
'Python'
,
'Python'
),
# Simple text literal
(
'.*Python'
,
'Python'
),
# Bad text literal
(
'.*Python.*'
,
'Python'
),
# Worse text literal
(
'.*(Python)'
,
'Python'
),
# Bad text literal with grouping
(
'(Python|Perl|Tcl'
,
'Perl'
),
# Alternation
(
'(Python|Perl|Tcl)'
,
'Perl'
),
# Grouped alternation
(
'(Python)
\
\
1'
,
'PythonPython'
),
# Backreference
(
'([0a-z][a-z]*,)+'
,
'a5,b7,c9,'
),
# Disable the fastmap optimization
(
'([a-z][a-z0-9]*,)+'
,
'a5,b7,c9,'
)
# A few sets
]
...
...
@@ -47,7 +47,7 @@ benchmarks = [
#
# If the regex isn't expected to work, the latter two elements can be omitted.
tests
=
[
tests
=
[
# Test ?P< and ?P= extensions
(
'(?P<foo_123'
,
''
,
SYNTAX_ERROR
),
# Unterminated group identifier
(
'(?P<1>a)'
,
''
,
SYNTAX_ERROR
),
# Begins with a digit
...
...
@@ -75,7 +75,7 @@ tests = [
(
r'[\0a]'
,
'
\
0
'
,
SUCCEED
,
'found'
,
'
\
0
'
),
(
r'[a\0]'
,
'
\
0
'
,
SUCCEED
,
'found'
,
'
\
0
'
),
(
r'[^a\0]'
,
'
\
0
'
,
FAIL
),
# Test various letter escapes
(
r'\a[\b]\f\n\r\t\v'
,
'
\
a
\
b
\
f
\
n
\
r
\
t
\
v
'
,
SUCCEED
,
'found'
,
'
\
a
\
b
\
f
\
n
\
r
\
t
\
v
'
),
(
r'[\a][\b][\f][\n][\r][\t][\v]'
,
'
\
a
\
b
\
f
\
n
\
r
\
t
\
v
'
,
SUCCEED
,
'found'
,
'
\
a
\
b
\
f
\
n
\
r
\
t
\
v
'
),
...
...
@@ -86,9 +86,9 @@ tests = [
(r'
\
x00f
', '
\
017
', SUCCEED, '
found
', chr(15)),
(r'
\
x00fe
', '
\
376
', SUCCEED, '
found
', chr(254)),
(r"^
\
w+=(
\
\
[
\
000-
\
277
]|[^
\
n
\
\
])*", "SRC=eval.c g.c blah blah blah
\
\
\
\
\
n
\
t
apes.c",
(r"^
\
w+=(
\
\
[
\
000-
\
277
]|[^
\
n
\
\
])*", "SRC=eval.c g.c blah blah blah
\
\
\
\
\
n
\
t
apes.c",
SUCCEED, '
found
', "SRC=eval.c g.c blah blah blah
\
\
\
\
"),
# Test that . only matches
\
n
in DOTALL mode
('
a
.
b', '
acb
', SUCCEED, '
found
', '
acb
'),
('
a
.
b', '
a
\
nb
', FAIL),
...
...
@@ -264,7 +264,7 @@ tests = [
('
\\
09
', chr(0) + '
9
', SUCCEED, '
found
', chr(0) + '
9
'),
('
\\
141
', '
a
', SUCCEED, '
found
', '
a
'),
('
(
a
)(
b
)(
c
)(
d
)(
e
)(
f
)(
g
)(
h
)(
i
)(
j
)(
k
)(
l
)
\\
119
', '
abcdefghijklk9
', SUCCEED, '
found
+
"-"
+
g11
', '
abcdefghijklk9
-
k
'),
# All tests from Perl
('
abc
', '
abc
', SUCCEED, '
found
', '
abc
'),
...
...
@@ -544,13 +544,13 @@ tests = [
# Check odd placement of embedded pattern modifiers
(
'w(?i)'
,
'W'
,
SYNTAX_ERROR
),
# Comments using the x embedded pattern modifier
(
"""(?x)w# comment 1
x y
# comment 2
z"""
,
'wxyz'
,
SUCCEED
,
'found'
,
'wxyz'
),
# comment 2
z"""
,
'wxyz'
,
SUCCEED
,
'found'
,
'wxyz'
),
# using the m embedded pattern modifier
...
...
@@ -564,7 +564,7 @@ xyz""", SUCCEED, 'found', 'abc'),
(
'(?m)abc$'
,
"""jkl
xyzabc
123"""
,
SUCCEED
,
'found'
,
'abc'
),
# using the s embedded pattern modifier
(
'a.b'
,
'a
\
n
b'
,
FAIL
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment