Skip to content

Commit a7153db

Browse files
committed
float tests: test non-determinism for more operations
1 parent 7d5fac7 commit a7153db

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/tools/miri/tests/pass/float.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,6 @@ fn test_non_determinism() {
13861386
frem_algebraic, frem_fast, fsub_algebraic, fsub_fast,
13871387
};
13881388
use std::{f32, f64};
1389-
// TODO: Also test powi and powf when the non-determinism is implemented for them
13901389

13911390
/// Ensure that the operation is non-deterministic
13921391
#[track_caller]
@@ -1426,21 +1425,23 @@ fn test_non_determinism() {
14261425
}
14271426
pub fn test_operations_f32(a: f32, b: f32) {
14281427
test_operations_f!(a, b);
1429-
// FIXME: temporarily disabled as it breaks std tests.
1430-
// ensure_nondet(|| a.log(b));
1431-
// ensure_nondet(|| a.exp());
1432-
// ensure_nondet(|| 10f32.exp2());
1433-
// ensure_nondet(|| f32::consts::E.ln());
1428+
// FIXME: some are temporarily disabled as it breaks std tests.
1429+
ensure_nondet(|| a.powf(b));
1430+
ensure_nondet(|| a.powi(2));
1431+
ensure_nondet(|| a.log(b));
1432+
ensure_nondet(|| a.exp());
1433+
ensure_nondet(|| 10f32.exp2());
1434+
ensure_nondet(|| f32::consts::E.ln());
1435+
ensure_nondet(|| 10f32.log10());
1436+
ensure_nondet(|| 8f32.log2());
14341437
// ensure_nondet(|| 1f32.ln_1p());
1435-
// ensure_nondet(|| 10f32.log10());
1436-
// ensure_nondet(|| 8f32.log2());
14371438
// ensure_nondet(|| 27.0f32.cbrt());
14381439
// ensure_nondet(|| 3.0f32.hypot(4.0f32));
1439-
// ensure_nondet(|| 1f32.sin());
1440-
// ensure_nondet(|| 0f32.cos());
1441-
// // On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
1442-
// // which means the little rounding errors Miri introduces are discard by the cast down to `f32`.
1443-
// // Just skip the test for them.
1440+
ensure_nondet(|| 1f32.sin());
1441+
ensure_nondet(|| 1f32.cos());
1442+
// On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
1443+
// which means the little rounding errors Miri introduces are discarded by the cast down to
1444+
// `f32`. Just skip the test for them.
14441445
// if !cfg!(all(target_os = "windows", target_env = "msvc", target_arch = "x86")) {
14451446
// ensure_nondet(|| 1.0f32.tan());
14461447
// ensure_nondet(|| 1.0f32.asin());
@@ -1461,18 +1462,20 @@ fn test_non_determinism() {
14611462
}
14621463
pub fn test_operations_f64(a: f64, b: f64) {
14631464
test_operations_f!(a, b);
1464-
// FIXME: temporarily disabled as it breaks std tests.
1465-
// ensure_nondet(|| a.log(b));
1466-
// ensure_nondet(|| a.exp());
1467-
// ensure_nondet(|| 50f64.exp2());
1468-
// ensure_nondet(|| 3f64.ln());
1465+
// FIXME: some are temporarily disabled as it breaks std tests.
1466+
ensure_nondet(|| a.powf(b));
1467+
ensure_nondet(|| a.powi(2));
1468+
ensure_nondet(|| a.log(b));
1469+
ensure_nondet(|| a.exp());
1470+
ensure_nondet(|| 50f64.exp2());
1471+
ensure_nondet(|| 3f64.ln());
1472+
ensure_nondet(|| f64::consts::E.log10());
1473+
ensure_nondet(|| f64::consts::E.log2());
14691474
// ensure_nondet(|| 1f64.ln_1p());
1470-
// ensure_nondet(|| f64::consts::E.log10());
1471-
// ensure_nondet(|| f64::consts::E.log2());
14721475
// ensure_nondet(|| 27.0f64.cbrt());
14731476
// ensure_nondet(|| 3.0f64.hypot(4.0f64));
1474-
// ensure_nondet(|| 1f64.sin());
1475-
// ensure_nondet(|| 0f64.cos());
1477+
ensure_nondet(|| 1f64.sin());
1478+
ensure_nondet(|| 1f64.cos());
14761479
// ensure_nondet(|| 1.0f64.tan());
14771480
// ensure_nondet(|| 1.0f64.asin());
14781481
// ensure_nondet(|| 5.0f64.acos());

0 commit comments

Comments
 (0)