Add float cmp const tests for arrays
This commit is contained in:
parent
3c738b2286
commit
c7b5e30423
@ -46,4 +46,17 @@ fn main() {
|
||||
v != w;
|
||||
v == 1.0;
|
||||
v != 1.0;
|
||||
|
||||
const ZERO_ARRAY: [f32; 3] = [0.0, 0.0, 0.0];
|
||||
const ZERO_INF_ARRAY: [f32; 3] = [0.0, ::std::f32::INFINITY, ::std::f32::NEG_INFINITY];
|
||||
const NON_ZERO_ARRAY: [f32; 3] = [0.0, 0.1, 0.2];
|
||||
const NON_ZERO_ARRAY2: [f32; 3] = [0.2, 0.1, 0.0];
|
||||
|
||||
// no errors, zero and infinity values
|
||||
NON_ZERO_ARRAY[0] == NON_ZERO_ARRAY2[1]; // lhs is 0.0
|
||||
ZERO_ARRAY == NON_ZERO_ARRAY; // lhs is all zeros
|
||||
ZERO_INF_ARRAY == NON_ZERO_ARRAY; // lhs is all zeros or infinities
|
||||
|
||||
// has errors
|
||||
NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
|
||||
}
|
||||
|
@ -83,5 +83,17 @@ note: `f32::EPSILON` and `f64::EPSILON` are available.
|
||||
LL | v != ONE;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: strict comparison of `f32` or `f64` constant
|
||||
--> $DIR/float_cmp_const.rs:61:5
|
||||
|
|
||||
LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `std::f32::EPSILON` and `std::f64::EPSILON` are available.
|
||||
--> $DIR/float_cmp_const.rs:61:5
|
||||
|
|
||||
LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user