mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Implement __floor__ for float type
Co-authored-by: Tetramad <cbwjd777@gmail.com>
This commit is contained in:
committed by
Tetramad
parent
fae7b0e8ed
commit
95b514b85d
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user