Skip to content

Commit

Permalink
add test checking behavior of matching on floats
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 24, 2023
1 parent 405a1c3 commit afe7676
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/ui/match/match-float.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-pass
// Makes sure we use `==` (not bitwise) semantics for float comparison.

fn main() {
const F1: f32 = 0.0;
const F2: f32 = -0.0;
assert_eq!(F1, F2);
assert_ne!(F1.to_bits(), F2.to_bits());
assert!(matches!(F1, F2));
assert!(matches!(F2, F1));
}

0 comments on commit afe7676

Please sign in to comment.