Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
f2cd2c1f
Commit
f2cd2c1f
authored
Apr 20, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple (failing) doctest test
with some minor changes to try to get it working
parent
59d38882
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
6 deletions
+79
-6
from_cpython/Lib/types.py
from_cpython/Lib/types.py
+4
-6
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+3
-0
test/tests/doctest_test.py
test/tests/doctest_test.py
+69
-0
test/tests/sys_test.py
test/tests/sys_test.py
+3
-0
No files found.
from_cpython/Lib/types.py
View file @
f2cd2c1f
...
@@ -64,20 +64,18 @@ ModuleType = type(sys)
...
@@ -64,20 +64,18 @@ ModuleType = type(sys)
FileType
=
file
FileType
=
file
XRangeType
=
xrange
XRangeType
=
xrange
# Pyston change: we don't support sys.exc_info yet
"""
try
:
try
:
raise
TypeError
raise
TypeError
except
TypeError
:
except
TypeError
:
tb
=
sys
.
exc_info
()[
2
]
tb
=
sys
.
exc_info
()[
2
]
TracebackType
=
type
(
tb
)
TracebackType
=
type
(
tb
)
FrameType = type(tb.tb_frame)
# Pyston change (we don't support tb_frame yet):
FrameType
=
type
(
sys
.
_getframe
(
0
))
# FrameType = type(tb.tb_frame)
del
tb
del
tb
"""
SliceType
=
slice
SliceType
=
slice
# Pyston change: don't support this yet
EllipsisType
=
type
(
Ellipsis
)
# EllipsisType = type(Ellipsis)
# Pyston change: don't support this yet
# Pyston change: don't support this yet
# DictProxyType = type(TypeType.__dict__)
# DictProxyType = type(TypeType.__dict__)
...
...
src/runtime/builtin_modules/sys.cpp
View file @
f2cd2c1f
...
@@ -278,6 +278,9 @@ void setupSys() {
...
@@ -278,6 +278,9 @@ void setupSys() {
sys_module
->
giveAttr
(
"stdout"
,
new
BoxedFile
(
stdout
,
"<stdout>"
,
"w"
));
sys_module
->
giveAttr
(
"stdout"
,
new
BoxedFile
(
stdout
,
"<stdout>"
,
"w"
));
sys_module
->
giveAttr
(
"stdin"
,
new
BoxedFile
(
stdin
,
"<stdin>"
,
"r"
));
sys_module
->
giveAttr
(
"stdin"
,
new
BoxedFile
(
stdin
,
"<stdin>"
,
"r"
));
sys_module
->
giveAttr
(
"stderr"
,
new
BoxedFile
(
stderr
,
"<stderr>"
,
"w"
));
sys_module
->
giveAttr
(
"stderr"
,
new
BoxedFile
(
stderr
,
"<stderr>"
,
"w"
));
sys_module
->
giveAttr
(
"__stdout__"
,
sys_module
->
getattr
(
"stdout"
));
sys_module
->
giveAttr
(
"__stdin__"
,
sys_module
->
getattr
(
"stdin"
));
sys_module
->
giveAttr
(
"__stderr__"
,
sys_module
->
getattr
(
"stderr"
));
sys_module
->
giveAttr
(
sys_module
->
giveAttr
(
"exc_info"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
sysExcInfo
,
BOXED_TUPLE
,
0
),
"exc_info"
));
"exc_info"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
sysExcInfo
,
BOXED_TUPLE
,
0
),
"exc_info"
));
...
...
test/tests/doctest_test.py
0 → 100644
View file @
f2cd2c1f
# expected: fail
# requires:
# - code.co_firstlineno
# - sys.dysplayhook
# - exec compile(foo) in globals_
# This is copied from the Python docs for doctest:
"""
This is the "example" module.
The example module supplies one function, factorial(). For example,
>>> factorial(5)
120
"""
def
factorial
(
n
):
"""Return the factorial of n, an exact integer >= 0.
If the result is small enough to fit in an int, return an int.
Else return a long.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> [factorial(long(n)) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30)
265252859812191058636308480000000L
>>> factorial(30L)
265252859812191058636308480000000L
>>> factorial(-1)
Traceback (most recent call last):
...
ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
...
ValueError: n must be exact integer
>>> factorial(30.0)
265252859812191058636308480000000L
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
...
OverflowError: n too large
"""
import
math
if
not
n
>=
0
:
raise
ValueError
(
"n must be >= 0"
)
if
math
.
floor
(
n
)
!=
n
:
raise
ValueError
(
"n must be exact integer"
)
if
n
+
1
==
n
:
# catch a value like 1e300
raise
OverflowError
(
"n too large"
)
result
=
1
factor
=
2
while
factor
<=
n
:
result
*=
factor
factor
+=
1
return
result
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
()
test/tests/sys_test.py
View file @
f2cd2c1f
...
@@ -8,3 +8,6 @@ print sys.byteorder
...
@@ -8,3 +8,6 @@ print sys.byteorder
print
sys
.
getdefaultencoding
()
print
sys
.
getdefaultencoding
()
print
sys
.
getfilesystemencoding
()
print
sys
.
getfilesystemencoding
()
print
type
(
sys
.
maxsize
)
print
type
(
sys
.
maxsize
)
print
sys
.
stdout
is
sys
.
__stdout__
print
sys
.
stderr
is
sys
.
__stderr__
print
sys
.
stdin
is
sys
.
__stdin__
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