diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py index 4232d85cc..a92f2dd1b 100644 --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -323,8 +323,6 @@ class FractionTest(unittest.TestCase): ValueError, "max_denominator should be at least 1", F(1).limit_denominator, i) - # TODO: RUSTPYTHON - @unittest.expectedFailure def testConversions(self): self.assertTypedEquals(-1, math.trunc(F(-11, 10))) self.assertTypedEquals(1, math.trunc(F(11, 10))) @@ -459,7 +457,6 @@ class FractionTest(unittest.TestCase): ) # TODO: RUSTPYTHON - @unittest.expectedFailure def testMixedArithmetic(self): self.assertTypedEquals(F(11, 10), F(1, 10) + 1) self.assertTypedEquals(1.1, F(1, 10) + 1.0) diff --git a/common/src/float_ops.rs b/common/src/float_ops.rs index f4089e064..268ca866b 100644 --- a/common/src/float_ops.rs +++ b/common/src/float_ops.rs @@ -182,7 +182,11 @@ pub fn div(v1: f64, v2: f64) -> Option { pub fn mod_(v1: f64, v2: f64) -> Option { if v2 != 0.0 { - Some(v1 % v2) + let mut val = v1 % v2; + if (val < 0.0) != (v2 < 0.0) { + val += v2; + } + Some(val) } else { None } diff --git a/vm/src/builtins/complex.rs b/vm/src/builtins/complex.rs index 203d79cc6..8ba88d419 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -180,7 +180,7 @@ impl PyComplex { other: PyObjectRef, vm: &VirtualMachine, ) -> PyResult> { - self.op(other, |a, b| a / b, vm) + self.op(other, |a, b| a.fdiv(b), vm) } #[pymethod(name = "__rtruediv__")]