From 9dadeb34dfd27a86051d8d7f4a5ffd4ee88d9775 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Sat, 23 May 2020 10:37:56 -0700 Subject: [PATCH] Test `is_nan` --- src/test/ui/consts/const-float-bits-conv.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/ui/consts/const-float-bits-conv.rs b/src/test/ui/consts/const-float-bits-conv.rs index 738d9f68c5c75..72b42a4b54c25 100644 --- a/src/test/ui/consts/const-float-bits-conv.rs +++ b/src/test/ui/consts/const-float-bits-conv.rs @@ -4,6 +4,7 @@ #![feature(const_panic)] #![feature(const_if_match)] #![feature(const_float_bits_conv)] +#![feature(const_float_classify)] // Don't promote const fn nop(x: T) -> T { x } @@ -44,6 +45,9 @@ fn f32() { const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; + const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); + const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); + const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); } @@ -69,6 +73,9 @@ fn f64() { const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; + const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); + const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); + const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); }