From 95b514b85dd428e99a4042ca80d7abd8b13b14df Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Sun, 14 Feb 2021 18:21:18 -0500 Subject: [PATCH] Implement __floor__ for float type Co-authored-by: Tetramad --- Lib/test/test_float.py | 2 -- vm/src/builtins/float.rs | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 1812ce0c8..ea00a8b99 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -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) diff --git a/vm/src/builtins/float.rs b/vm/src/builtins/float.rs index b4e16ec23..af7e477a4 100644 --- a/vm/src/builtins/float.rs +++ b/vm/src/builtins/float.rs @@ -389,6 +389,11 @@ impl PyFloat { try_bigint(self.value, vm) } + #[pymethod(magic)] + fn floor(&self, vm: &VirtualMachine) -> PyResult { + try_bigint(self.value.floor(), vm) + } + #[pymethod(magic)] fn ceil(&self, vm: &VirtualMachine) -> PyResult { try_bigint(self.value.ceil(), vm)