Skip to content

Commit 199c92c

Browse files
2 more crashes fixed
1 parent 4ea76ec commit 199c92c

File tree

1 file changed

+11
-11
lines changed
  • library/std/tests/floats

1 file changed

+11
-11
lines changed

library/std/tests/floats/f32.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const NAN_MASK2: u32 = 0x0055_5555;
2525
/// Miri adds some extra errors to float functions; make sure the tests still pass.
2626
/// These values are purely used as a canary to test against and are thus not a stable guarantee Rust provides.
2727
/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
28-
const APPROX_DETLA: f32 = if cfg!(miri) { 1e-4 } else { 1e-6 };
28+
const APPROX_DELTA: f32 = if cfg!(miri) { 1e-4 } else { 1e-6 };
2929

3030
#[allow(unused_macros)]
3131
macro_rules! assert_f32_biteq {
@@ -451,7 +451,7 @@ fn test_powi() {
451451
assert_approx_eq!(
452452
(-3.1f32).powi(2),
453453
9.61,
454-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
454+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
455455
);
456456
assert_approx_eq!(5.9f32.powi(-2), 0.028727);
457457
assert_eq!(8.3f32.powi(0), 1.0);
@@ -469,13 +469,13 @@ fn test_powf() {
469469
assert_approx_eq!(
470470
3.4f32.powf(4.5),
471471
246.408218,
472-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
472+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
473473
);
474474
assert_approx_eq!(2.7f32.powf(-3.2), 0.041652);
475475
assert_approx_eq!(
476476
(-3.1f32).powf(2.0),
477477
9.61,
478-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
478+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
479479
);
480480
assert_approx_eq!(5.9f32.powf(-2.0), 0.028727);
481481
assert_eq!(8.3f32.powf(0.0), 1.0);
@@ -498,11 +498,11 @@ fn test_sqrt_domain() {
498498
#[test]
499499
fn test_exp() {
500500
assert_eq!(1.0, 0.0f32.exp());
501-
assert_approx_eq!(2.718282, 1.0f32.exp());
501+
assert_approx_eq!(2.718282, 1.0f32.exp(), APPROX_DELTA);
502502
assert_approx_eq!(
503503
148.413162,
504504
5.0f32.exp(),
505-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
505+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
506506
);
507507

508508
let inf: f32 = f32::INFINITY;
@@ -518,7 +518,7 @@ fn test_exp2() {
518518
assert_approx_eq!(
519519
32.0,
520520
5.0f32.exp2(),
521-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
521+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
522522
);
523523
assert_eq!(1.0, 0.0f32.exp2());
524524

@@ -545,7 +545,7 @@ fn test_ln() {
545545
assert_approx_eq!(
546546
4.0f32.ln(),
547547
1.386294,
548-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
548+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
549549
);
550550
}
551551

@@ -671,7 +671,7 @@ fn test_acosh() {
671671
assert_approx_eq!(
672672
60.0f32,
673673
60.0f32.cosh().acosh(),
674-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
674+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
675675
);
676676
}
677677

@@ -754,7 +754,7 @@ fn test_real_consts() {
754754
assert_approx_eq!(
755755
frac_pi_3,
756756
pi / 3f32,
757-
APPROX_DETLA /* Miri float-non-det: Make tests pass for now */
757+
APPROX_DELTA /* Miri float-non-det: Make tests pass for now */
758758
);
759759
assert_approx_eq!(frac_pi_4, pi / 4f32);
760760
assert_approx_eq!(frac_pi_6, pi / 6f32);
@@ -767,7 +767,7 @@ fn test_real_consts() {
767767
assert_approx_eq!(log2_e, e.log2());
768768
assert_approx_eq!(log10_e, e.log10());
769769
assert_approx_eq!(ln_2, 2f32.ln());
770-
assert_approx_eq!(ln_10, 10f32.ln());
770+
assert_approx_eq!(ln_10, 10f32.ln(), APPROX_DELTA);
771771
}
772772

773773
#[test]

0 commit comments

Comments
 (0)