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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
d7ac5174
Commit
d7ac5174
authored
Mar 19, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend tests to include an ambiguity in Python 3.x grammar: "e" for exponent or start of "else"
parent
0c1a8b4d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
Cython/Compiler/Tests/TestGrammar.py
Cython/Compiler/Tests/TestGrammar.py
+23
-0
tests/run/int_literals.pyx
tests/run/int_literals.pyx
+2
-0
No files found.
Cython/Compiler/Tests/TestGrammar.py
View file @
d7ac5174
...
...
@@ -57,6 +57,13 @@ INVALID_UNDERSCORE_LITERALS = [
'._5'
,
]
UNDERSCORE_EXPRESSIONS
=
[
(
'0 if 1_____else 1'
,
True
),
(
'0 if 1_____Else 1'
,
False
),
(
'0 if 1.0_____else 1'
,
True
),
(
'0 if 1.0_____Else 1'
,
False
),
]
class
TestGrammar
(
CythonTest
):
...
...
@@ -81,6 +88,22 @@ class TestGrammar(CythonTest):
# cython: language_level=3
'''
+
code
)
is
not
None
def
test_underscore_number_expressions
(
self
):
for
expression
,
is_valid
in
UNDERSCORE_EXPRESSIONS
:
code
=
'x = '
+
expression
fragment
=
u'''
\
# cython: language_level=3
'''
+
code
if
is_valid
:
assert
self
.
fragment
(
fragment
)
is
not
None
else
:
try
:
self
.
fragment
(
fragment
)
except
CompileError
as
exc
:
assert
code
in
[
s
.
strip
()
for
s
in
str
(
exc
).
splitlines
()],
str
(
exc
)
else
:
assert
False
,
"Invalid Cython code '%s' failed to raise an exception"
%
code
if
__name__
==
"__main__"
:
import
unittest
...
...
tests/run/int_literals.pyx
View file @
d7ac5174
...
...
@@ -35,6 +35,8 @@ def valid_underscore_literals():
assert
0b1
_
==
0b1
assert
0xf
_
==
0xf
assert
0o5
_
==
0o5
assert
(
0
if
1
_____else
1
)
==
0
assert
(
0
if
1.0
_____else
1
)
==
0
@
cython
.
test_assert_path_exists
(
...
...
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