Implement __floor__ for float type

Co-authored-by: Tetramad <cbwjd777@gmail.com>
This commit is contained in:
Padraic FanningandTetramad authored and Tetramad committed 2021-08-11 14:30:10 +09:00
1 parent fae7b0e8ed
commit 95b514b85d
2 files changed
+5 -2

No files matched your search

-2
View File
@@ -324,8 +324,6 @@ class GeneralFloatCases(unittest.TestCase):
# distinguishes -0.0 and 0.0.
self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_float_floor(self):
self.assertIsInstance(float(0.5).__floor__(), int)
self.assertEqual(float(0.5).__floor__(), 0)
+5
View File
@@ -389,6 +389,11 @@ impl PyFloat {
try_bigint(self.value, vm)
}
#[pymethod(magic)]
fn floor(&self, vm: &VirtualMachine) -> PyResult<BigInt> {
try_bigint(self.value.floor(), vm)
}
#[pymethod(magic)]
fn ceil(&self, vm: &VirtualMachine) -> PyResult<BigInt> {
try_bigint(self.value.ceil(), vm)