]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-fail/float_cmp.rs
Use `span_suggestion` in `FLOAT_CMP`
[rust.git] / tests / compile-fail / float_cmp.rs
index 9f611dd3fd917c54b0b2db7068dbe2f3ccdd9c28..cf8cefb3af3e0be41be6a32d1fcd44167d0f8688 100644 (file)
@@ -40,23 +40,47 @@ fn main() {
     ZERO == 0.0; //no error, comparison with zero is ok
     ZERO + ZERO != 1.0; //no error, comparison with zero is ok
 
-    ONE == 1f32; //~ERROR ==-comparison of f32 or f64
-    ONE == (1.0 + 0.0); //~ERROR ==-comparison of f32 or f64
-
-    ONE + ONE == (ZERO + ONE + ONE); //~ERROR ==-comparison of f32 or f64
-
-    ONE != 2.0; //~ERROR !=-comparison of f32 or f64
+    ONE == 1f32;
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (ONE - 1f32).abs() < error
+    ONE == (1.0 + 0.0);
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (ONE - (1.0 + 0.0)).abs() < error
+
+    ONE + ONE == (ZERO + ONE + ONE);
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (ONE + ONE - (ZERO + ONE + ONE)).abs() < error
+
+    ONE != 2.0;
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (ONE - 2.0).abs() < error
     ONE != 0.0; // no error, comparison with zero is ok
-    twice(ONE) != ONE; //~ERROR !=-comparison of f32 or f64
-    ONE as f64 != 2.0; //~ERROR !=-comparison of f32 or f64
+    twice(ONE) != ONE;
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (twice(ONE) - ONE).abs() < error
+    ONE as f64 != 2.0;
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (ONE as f64 - 2.0).abs() < error
     ONE as f64 != 0.0; // no error, comparison with zero is ok
 
     let x : f64 = 1.0;
 
-    x == 1.0; //~ERROR ==-comparison of f32 or f64
+    x == 1.0;
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (x - 1.0).abs() < error
     x != 0f64; // no error, comparison with zero is ok
 
-    twice(x) != twice(ONE as f64); //~ERROR !=-comparison of f32 or f64
+    twice(x) != twice(ONE as f64);
+    //~^ ERROR strict comparison of f32 or f64
+    //~| HELP within some error
+    //~| SUGGESTION (twice(x) - twice(ONE as f64)).abs() < error
 
 
     x < 0.0; // no errors, lower or greater comparisons need no fuzzyness