Fix math.log10 to pass some failed tests

Now math.log10 with less than or equal to zero should raise ValueError
with "math domain error" message if `x` fit in f64
This commit is contained in:
Tetramad
2021-10-25 11:45:03 +09:00
parent 2bedba0e12
commit ebd0352cfc

View File

@@ -166,7 +166,12 @@ mod math {
#[pyfunction]
fn log10(x: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {
call_math_func!(log10, x, vm)
let x = x.to_f64();
if x.is_nan() || x > 0.0_f64 {
Ok(x.log10())
} else {
Err(vm.new_value_error("math domain error".to_owned()))
}
}
#[pyfunction]