Skip to content

Commit 8893cf3

Browse files
committed
float tests: test non-determinism for more operations
1 parent 1875a48 commit 8893cf3

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

tests/pass/float.rs

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

12831282
/// Ensure that the operation is non-deterministic
12841283
#[track_caller]
@@ -1318,21 +1317,23 @@ fn test_non_determinism() {
13181317
}
13191318
pub fn test_operations_f32(a: f32, b: f32) {
13201319
test_operations_f!(a, b);
1321-
// FIXME: temporarily disabled as it breaks std tests.
1322-
// ensure_nondet(|| a.log(b));
1323-
// ensure_nondet(|| a.exp());
1324-
// ensure_nondet(|| 10f32.exp2());
1325-
// ensure_nondet(|| f32::consts::E.ln());
1320+
// FIXME: some are temporarily disabled as it breaks std tests.
1321+
ensure_nondet(|| a.powf(b));
1322+
ensure_nondet(|| a.powi(2));
1323+
ensure_nondet(|| a.log(b));
1324+
ensure_nondet(|| a.exp());
1325+
ensure_nondet(|| 10f32.exp2());
1326+
ensure_nondet(|| f32::consts::E.ln());
1327+
ensure_nondet(|| 10f32.log10());
1328+
ensure_nondet(|| 8f32.log2());
13261329
// ensure_nondet(|| 1f32.ln_1p());
1327-
// ensure_nondet(|| 10f32.log10());
1328-
// ensure_nondet(|| 8f32.log2());
13291330
// ensure_nondet(|| 27.0f32.cbrt());
13301331
// ensure_nondet(|| 3.0f32.hypot(4.0f32));
1331-
// ensure_nondet(|| 1f32.sin());
1332-
// ensure_nondet(|| 0f32.cos());
1333-
// // On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
1334-
// // which means the little rounding errors Miri introduces are discard by the cast down to `f32`.
1335-
// // Just skip the test for them.
1332+
ensure_nondet(|| 1f32.sin());
1333+
ensure_nondet(|| 0f32.cos());
1334+
// On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
1335+
// which means the little rounding errors Miri introduces are discarded by the cast down to
1336+
// `f32`. Just skip the test for them.
13361337
// if !cfg!(all(target_os = "windows", target_env = "msvc", target_arch = "x86")) {
13371338
// ensure_nondet(|| 1.0f32.tan());
13381339
// ensure_nondet(|| 1.0f32.asin());
@@ -1353,18 +1354,20 @@ fn test_non_determinism() {
13531354
}
13541355
pub fn test_operations_f64(a: f64, b: f64) {
13551356
test_operations_f!(a, b);
1356-
// FIXME: temporarily disabled as it breaks std tests.
1357-
// ensure_nondet(|| a.log(b));
1358-
// ensure_nondet(|| a.exp());
1359-
// ensure_nondet(|| 50f64.exp2());
1360-
// ensure_nondet(|| 3f64.ln());
1357+
// FIXME: some are temporarily disabled as it breaks std tests.
1358+
ensure_nondet(|| a.powf(b));
1359+
ensure_nondet(|| a.powi(2));
1360+
ensure_nondet(|| a.log(b));
1361+
ensure_nondet(|| a.exp());
1362+
ensure_nondet(|| 50f64.exp2());
1363+
ensure_nondet(|| 3f64.ln());
1364+
ensure_nondet(|| f64::consts::E.log10());
1365+
ensure_nondet(|| f64::consts::E.log2());
13611366
// ensure_nondet(|| 1f64.ln_1p());
1362-
// ensure_nondet(|| f64::consts::E.log10());
1363-
// ensure_nondet(|| f64::consts::E.log2());
13641367
// ensure_nondet(|| 27.0f64.cbrt());
13651368
// ensure_nondet(|| 3.0f64.hypot(4.0f64));
1366-
// ensure_nondet(|| 1f64.sin());
1367-
// ensure_nondet(|| 0f64.cos());
1369+
ensure_nondet(|| 1f64.sin());
1370+
ensure_nondet(|| 0f64.cos());
13681371
// ensure_nondet(|| 1.0f64.tan());
13691372
// ensure_nondet(|| 1.0f64.asin());
13701373
// ensure_nondet(|| 5.0f64.acos());

0 commit comments

Comments
 (0)