mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Implement __ceil__ for float type
Co-authored-by: Tetramad <cbwjd777@gmail.com>
This commit is contained in:
1 parent
9f497fb65a
commit
fae7b0e8ed
2 files changed
+5
-2
No files matched your search
@@ -340,8 +340,6 @@ class GeneralFloatCases(unittest.TestCase):
|
||||
self.assertRaises(OverflowError, float("inf").__floor__)
|
||||
self.assertRaises(OverflowError, float("-inf").__floor__)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_float_ceil(self):
|
||||
self.assertIsInstance(float(0.5).__ceil__(), int)
|
||||
self.assertEqual(float(0.5).__ceil__(), 1)
|
||||
|
||||
@@ -389,6 +389,11 @@ impl PyFloat {
|
||||
try_bigint(self.value, vm)
|
||||
}
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn ceil(&self, vm: &VirtualMachine) -> PyResult<BigInt> {
|
||||
try_bigint(self.value.ceil(), vm)
|
||||
}
|
||||
|
||||
#[pymethod(name = "__round__")]
|
||||
fn round(&self, ndigits: OptionalOption<PyIntRef>, vm: &VirtualMachine) -> PyResult {
|
||||
let ndigits = ndigits.flatten();
|
||||
|
||||
Reference in new issue
Block a user