mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-07 20:43:03 +00:00
add more negative tests
This commit is contained in:
parent
2787a60fc2
commit
cd3106d99f
@ -28,4 +28,17 @@ fn main() {
|
|||||||
v > ONE;
|
v > ONE;
|
||||||
v <= ONE;
|
v <= ONE;
|
||||||
v >= ONE;
|
v >= ONE;
|
||||||
|
|
||||||
|
// has float_cmp warns (as expected), no float constants
|
||||||
|
let w = 1.1;
|
||||||
|
v == w;
|
||||||
|
v != w;
|
||||||
|
v == 1.0;
|
||||||
|
v != 1.0;
|
||||||
|
|
||||||
|
// no errors, zero and infinity values
|
||||||
|
ONE != 0f32;
|
||||||
|
TWO == 0f32;
|
||||||
|
ONE != ::std::f32::INFINITY;
|
||||||
|
ONE == ::std::f32::NEG_INFINITY;
|
||||||
}
|
}
|
||||||
|
@ -83,3 +83,52 @@ note: std::f32::EPSILON and std::f64::EPSILON are available.
|
|||||||
24 | v != ONE;
|
24 | v != ONE;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: strict comparison of f32 or f64
|
||||||
|
--> $DIR/float_cmp_const.rs:34:5
|
||||||
|
|
|
||||||
|
34 | v == w;
|
||||||
|
| ^^^^^^ help: consider comparing them within some error: `(v - w).abs() < error`
|
||||||
|
|
|
||||||
|
= note: `-D float-cmp` implied by `-D warnings`
|
||||||
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
|
||||||
|
--> $DIR/float_cmp_const.rs:34:5
|
||||||
|
|
|
||||||
|
34 | v == w;
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: strict comparison of f32 or f64
|
||||||
|
--> $DIR/float_cmp_const.rs:35:5
|
||||||
|
|
|
||||||
|
35 | v != w;
|
||||||
|
| ^^^^^^ help: consider comparing them within some error: `(v - w).abs() < error`
|
||||||
|
|
|
||||||
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
|
||||||
|
--> $DIR/float_cmp_const.rs:35:5
|
||||||
|
|
|
||||||
|
35 | v != w;
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: strict comparison of f32 or f64
|
||||||
|
--> $DIR/float_cmp_const.rs:36:5
|
||||||
|
|
|
||||||
|
36 | v == 1.0;
|
||||||
|
| ^^^^^^^^ help: consider comparing them within some error: `(v - 1.0).abs() < error`
|
||||||
|
|
|
||||||
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
|
||||||
|
--> $DIR/float_cmp_const.rs:36:5
|
||||||
|
|
|
||||||
|
36 | v == 1.0;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: strict comparison of f32 or f64
|
||||||
|
--> $DIR/float_cmp_const.rs:37:5
|
||||||
|
|
|
||||||
|
37 | v != 1.0;
|
||||||
|
| ^^^^^^^^ help: consider comparing them within some error: `(v - 1.0).abs() < error`
|
||||||
|
|
|
||||||
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
|
||||||
|
--> $DIR/float_cmp_const.rs:37:5
|
||||||
|
|
|
||||||
|
37 | v != 1.0;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user