Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
efe9d6a9
Commit
efe9d6a9
authored
Dec 10, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some unit tests for the build system.
parent
b18d94e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
7 deletions
+65
-7
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+7
-7
Cython/Build/Tests/TestStripLiterals.py
Cython/Build/Tests/TestStripLiterals.py
+57
-0
Cython/Build/Tests/__init__.py
Cython/Build/Tests/__init__.py
+0
-0
setup.py
setup.py
+1
-0
No files found.
Cython/Build/Dependencies.py
View file @
efe9d6a9
...
@@ -168,7 +168,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
...
@@ -168,7 +168,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
# Try to close the quote.
# Try to close the quote.
elif
in_quote
:
elif
in_quote
:
if
code
[
q
-
1
]
==
'
\
\
'
:
if
code
[
q
-
1
]
==
'
\
\
'
and
not
raw
:
k
=
2
k
=
2
while
q
>=
k
and
code
[
q
-
k
]
==
'
\
\
'
:
while
q
>=
k
and
code
[
q
-
k
]
==
'
\
\
'
:
k
+=
1
k
+=
1
...
@@ -177,7 +177,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
...
@@ -177,7 +177,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
continue
continue
if
code
[
q
:
q
+
len
(
in_quote
)]
==
in_quote
:
if
code
[
q
:
q
+
len
(
in_quote
)]
==
in_quote
:
counter
+=
1
counter
+=
1
label
=
"%s%s"
%
(
prefix
,
counter
)
label
=
"%s%s
_
"
%
(
prefix
,
counter
)
literals
[
label
]
=
code
[
start
+
len
(
in_quote
):
q
]
literals
[
label
]
=
code
[
start
+
len
(
in_quote
):
q
]
new_code
.
append
(
"%s%s%s"
%
(
in_quote
,
label
,
in_quote
))
new_code
.
append
(
"%s%s%s"
%
(
in_quote
,
label
,
in_quote
))
q
+=
len
(
in_quote
)
q
+=
len
(
in_quote
)
...
@@ -193,7 +193,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
...
@@ -193,7 +193,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
end
=
None
end
=
None
new_code
.
append
(
code
[
start
:
hash_mark
+
1
])
new_code
.
append
(
code
[
start
:
hash_mark
+
1
])
counter
+=
1
counter
+=
1
label
=
"%s%s"
%
(
prefix
,
counter
)
label
=
"%s%s
_
"
%
(
prefix
,
counter
)
literals
[
label
]
=
code
[
hash_mark
+
1
:
end
]
literals
[
label
]
=
code
[
hash_mark
+
1
:
end
]
new_code
.
append
(
label
)
new_code
.
append
(
label
)
if
end
is
None
:
if
end
is
None
:
...
@@ -208,11 +208,11 @@ def strip_string_literals(code, prefix='__Pyx_L'):
...
@@ -208,11 +208,11 @@ def strip_string_literals(code, prefix='__Pyx_L'):
in_quote
=
code
[
q
]
*
3
in_quote
=
code
[
q
]
*
3
else
:
else
:
in_quote
=
code
[
q
]
in_quote
=
code
[
q
]
end
=
q
end
=
marker
=
q
while
end
>
0
and
code
[
end
-
1
]
in
'rRbBuU'
:
while
marker
>
0
and
code
[
marker
-
1
]
in
'rRbBuU'
:
if
code
[
end
-
1
]
in
'rR'
:
if
code
[
marker
-
1
]
in
'rR'
:
raw
=
True
raw
=
True
end
-=
1
marker
-=
1
new_code
.
append
(
code
[
start
:
end
])
new_code
.
append
(
code
[
start
:
end
])
start
=
q
start
=
q
q
+=
len
(
in_quote
)
q
+=
len
(
in_quote
)
...
...
Cython/Build/Tests/TestStripLiterals.py
0 → 100644
View file @
efe9d6a9
from
Cython.Build.Dependencies
import
strip_string_literals
from
Cython.TestUtils
import
CythonTest
class
TestStripLiterals
(
CythonTest
):
def
t
(
self
,
before
,
expected
):
actual
,
literals
=
strip_string_literals
(
before
,
prefix
=
"_L"
)
self
.
assertEquals
(
expected
,
actual
)
for
key
,
value
in
literals
.
items
():
actual
=
actual
.
replace
(
key
,
value
)
self
.
assertEquals
(
before
,
actual
)
def
test_empty
(
self
):
self
.
t
(
""
,
""
)
def
test_single_quote
(
self
):
self
.
t
(
"'x'"
,
"'_L1_'"
)
def
test_double_quote
(
self
):
self
.
t
(
'"x"'
,
'"_L1_"'
)
def
test_nested_quotes
(
self
):
self
.
t
(
""" '"' "'" """
,
""" '_L1_' "_L2_" """
)
def
test_triple_quote
(
self
):
self
.
t
(
" '''a
\
n
''' "
,
" '''_L1_''' "
)
def
test_backslash
(
self
):
self
.
t
(
r"'a\'b'"
,
"'_L1_'"
)
self
.
t
(
r"'a\\'"
,
"'_L1_'"
)
self
.
t
(
r"'a\\\'b'"
,
"'_L1_'"
)
def
test_unicode
(
self
):
self
.
t
(
"u'abc'"
,
"u'_L1_'"
)
def
test_raw
(
self
):
self
.
t
(
r"r'abc\'"
,
"r'_L1_'"
)
def
test_raw_unicode
(
self
):
self
.
t
(
r"ru'abc\'"
,
"ru'_L1_'"
)
def
test_comment
(
self
):
self
.
t
(
"abc # foo"
,
"abc #_L1_"
)
def
test_comment_and_quote
(
self
):
self
.
t
(
"abc # 'x'"
,
"abc #_L1_"
)
self
.
t
(
"'abc#'"
,
"'_L1_'"
)
def
test_include
(
self
):
self
.
t
(
"include 'a.pxi' # something here"
,
"include '_L1_' #_L2_"
)
def
test_extern
(
self
):
self
.
t
(
"cdef extern from 'a.h': # comment"
,
"cdef extern from '_L1_': #_L2_"
)
Cython/Build/Tests/__init__.py
0 → 100644
View file @
efe9d6a9
setup.py
View file @
efe9d6a9
...
@@ -264,6 +264,7 @@ packages = [
...
@@ -264,6 +264,7 @@ packages = [
'Cython.Distutils'
,
'Cython.Distutils'
,
'Cython.Plex'
,
'Cython.Plex'
,
'Cython.Tests'
,
'Cython.Tests'
,
'Cython.Build.Tests'
,
'Cython.Compiler.Tests'
,
'Cython.Compiler.Tests'
,
]
]
...
...
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