diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index cffe573cc..ac505a011 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -249,7 +249,6 @@ class MathTests(unittest.TestCase): self.ftest('e', math.e, 2.718281828459045235360287) self.assertEqual(math.tau, 2*math.pi) - @unittest.skip('TODO: RUSTPYTHON') def testAcos(self): self.assertRaises(TypeError, math.acos) self.ftest('acos(-1)', math.acos(-1), math.pi) @@ -272,7 +271,6 @@ class MathTests(unittest.TestCase): self.assertRaises(ValueError, math.acosh, NINF) self.assertTrue(math.isnan(math.acosh(NAN))) - @unittest.skip('TODO: RUSTPYTHON') def testAsin(self): self.assertRaises(TypeError, math.asin) self.ftest('asin(-1)', math.asin(-1), -math.pi/2) diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index f0e5f7ef4..3f75f9228 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -136,8 +136,24 @@ fn math_sqrt(value: IntoPyFloat, vm: &VirtualMachine) -> PyResult { } // Trigonometric functions: -make_math_func!(math_acos, acos); -make_math_func!(math_asin, asin); +fn math_acos(x: IntoPyFloat, vm: &VirtualMachine) -> PyResult { + let x = x.to_f64(); + if x.is_nan() || (-1.0_f64..=1.0_f64).contains(&x) { + Ok(x.acos()) + } else { + Err(vm.new_value_error("math domain error".to_owned())) + } +} + +fn math_asin(x: IntoPyFloat, vm: &VirtualMachine) -> PyResult { + let x = x.to_f64(); + if x.is_nan() || (-1.0_f64..=1.0_f64).contains(&x) { + Ok(x.asin()) + } else { + Err(vm.new_value_error("math domain error".to_owned())) + } +} + make_math_func!(math_atan, atan); fn math_atan2(y: IntoPyFloat, x: IntoPyFloat) -> f64 {