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
904c80c7
Commit
904c80c7
authored
Dec 21, 2015
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing float attributes and tests
parent
1c4c40a9
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
14 deletions
+193
-14
from_cpython/Objects/floatobject.c
from_cpython/Objects/floatobject.c
+6
-3
src/runtime/float.cpp
src/runtime/float.cpp
+132
-11
test/tests/float.py
test/tests/float.py
+25
-0
test/tests/long.py
test/tests/long.py
+30
-0
No files found.
from_cpython/Objects/floatobject.c
View file @
904c80c7
...
@@ -747,7 +747,8 @@ float_rem(PyObject *v, PyObject *w)
...
@@ -747,7 +747,8 @@ float_rem(PyObject *v, PyObject *w)
return
PyFloat_FromDouble
(
mod
);
return
PyFloat_FromDouble
(
mod
);
}
}
static
PyObject
*
// pyston change: make this not static
PyObject
*
float_divmod
(
PyObject
*
v
,
PyObject
*
w
)
float_divmod
(
PyObject
*
v
,
PyObject
*
w
)
{
{
double
vx
,
wx
;
double
vx
,
wx
;
...
@@ -987,7 +988,8 @@ float_nonzero(PyFloatObject *v)
...
@@ -987,7 +988,8 @@ float_nonzero(PyFloatObject *v)
return
v
->
ob_fval
!=
0
.
0
;
return
v
->
ob_fval
!=
0
.
0
;
}
}
static
int
// pyston change: make not static
int
float_coerce
(
PyObject
**
pv
,
PyObject
**
pw
)
float_coerce
(
PyObject
**
pv
,
PyObject
**
pw
)
{
{
if
(
PyInt_Check
(
*
pw
))
{
if
(
PyInt_Check
(
*
pw
))
{
...
@@ -1949,7 +1951,8 @@ PyDoc_STRVAR(float_getformat_doc,
...
@@ -1949,7 +1951,8 @@ PyDoc_STRVAR(float_getformat_doc,
"'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the
\n
"
"'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the
\n
"
"format of floating point numbers used by the C type named by typestr."
);
"format of floating point numbers used by the C type named by typestr."
);
static
PyObject
*
// pyston change: make not static
PyObject
*
float_setformat
(
PyTypeObject
*
v
,
PyObject
*
args
)
float_setformat
(
PyTypeObject
*
v
,
PyObject
*
args
)
{
{
char
*
typestr
;
char
*
typestr
;
...
...
src/runtime/float.cpp
View file @
904c80c7
This diff is collapsed.
Click to expand it.
test/tests/float.py
View file @
904c80c7
...
@@ -111,3 +111,28 @@ print sys.float_info
...
@@ -111,3 +111,28 @@ print sys.float_info
if
1
:
if
1
:
x
=
-
2.0
x
=
-
2.0
print
(
float
.
__long__
(
sys
.
float_info
.
max
))
print
(
float
.
__int__
(
sys
.
float_info
.
max
))
data
=
[
"-1.0"
,
"0.0"
,
"1.0"
,
"5.0"
,
"-5.0"
,
"5"
,
"5L"
,
"0L"
,
"5+5j"
,
"
\
"
5
\
"
"
,
"None"
,
]
operations
=
[
"__rpow__"
,
"__divmod__"
,
"__rdivmod__"
,
"__rtruediv__"
,
"__coerce__"
]
for
x
in
data
:
for
y
in
data
:
for
operation
in
operations
:
try
:
print
(
eval
(
"float.{op}({arg1}, {arg2})"
.
format
(
op
=
operation
,
arg1
=
x
,
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
test/tests/long.py
View file @
904c80c7
...
@@ -162,3 +162,33 @@ for i in range(-10, 10):
...
@@ -162,3 +162,33 @@ for i in range(-10, 10):
for
i
in
xrange
(
100
):
for
i
in
xrange
(
100
):
for
j
in
xrange
(
100
):
for
j
in
xrange
(
100
):
print
i
,
j
,
hash
((
1
<<
i
)
-
(
1
<<
j
))
print
i
,
j
,
hash
((
1
<<
i
)
-
(
1
<<
j
))
unary_test_data
=
[
-
42
,
-
0
,
0
,
42
]
for
i
in
unary_test_data
:
print
(
int
.
__abs__
(
i
))
print
(
int
.
__long__
(
i
))
data
=
[
"-1L"
,
"0L"
,
"1L"
,
"42L"
,
"-42L"
,
"42.0"
,
"5"
,
"0"
,
"5+5j"
,
"0.0"
,
"
\
"
42
\
"
"
,
"None"
,
]
operations
=
[
"__rpow__"
,
"__rshift__"
,
"__lshift__"
,
"__rrshift__"
,
"__rlshift__"
,
"__coerce__"
,
]
for
x
in
data
:
for
y
in
data
:
for
operation
in
operations
:
try
:
print
(
eval
(
"long.{op}({arg1}, {arg2})"
.
format
(
op
=
operation
,
arg1
=
x
,
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
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