diff options
| author | briankabiro <briankigondu@gmail.com> | 2019-09-19 15:57:43 +0300 |
|---|---|---|
| committer | Marcin Serwin <toxyxer@gmail.com> | 2020-04-09 08:05:51 +0200 |
| commit | 0d00eafd3297cfd67a1af3ff053bab8ef5f1ca12 (patch) | |
| tree | 4533fd3c7331fc66b39b5b7789551d7edb4abe36 | |
| parent | d4409350dc38a4ee22f86ff39f5613b37a2c5771 (diff) | |
| download | rust-0d00eafd3297cfd67a1af3ff053bab8ef5f1ca12.tar.gz rust-0d00eafd3297cfd67a1af3ff053bab8ef5f1ca12.zip | |
Add tests for float in array comparison
| -rw-r--r-- | tests/ui/float_cmp.rs | 7 | ||||
| -rw-r--r-- | tests/ui/float_cmp.stderr | 28 |
2 files changed, 34 insertions, 1 deletions
diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index c8248723bc9..b5c6a6449c2 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -77,6 +77,13 @@ fn main() { assert_eq!(a, b); // no errors + let a1: [f32; 1] = [0.0]; + let a2: [f32; 1] = [1.1]; + + assert_eq!(a1[0], a2[0]); + + assert_eq!(&a1[0], &a2[0]); + // no errors - comparing signums is ok let x32 = 3.21f32; 1.23f32.signum() == x32.signum(); diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 90c25a6db37..7a55aeed3a3 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -35,5 +35,31 @@ note: `f32::EPSILON` and `f64::EPSILON` are available. LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: strict comparison of f32 or f64 + --> $DIR/float_cmp.rs:83:5 + | +LL | assert_eq!(a1[0], a2[0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: std::f32::EPSILON and std::f64::EPSILON are available. + --> $DIR/float_cmp.rs:83:5 + | +LL | assert_eq!(a1[0], a2[0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: strict comparison of f32 or f64 + --> $DIR/float_cmp.rs:85:5 + | +LL | assert_eq!(&a1[0], &a2[0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: std::f32::EPSILON and std::f64::EPSILON are available. + --> $DIR/float_cmp.rs:85:5 + | +LL | assert_eq!(&a1[0], &a2[0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 5 previous errors |
