summaryrefslogtreecommitdiffstats
path: root/src/test/ui/numbers-arithmetic/u128-as-f32.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/numbers-arithmetic/u128-as-f32.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/numbers-arithmetic/u128-as-f32.rs')
-rw-r--r--src/test/ui/numbers-arithmetic/u128-as-f32.rs46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/test/ui/numbers-arithmetic/u128-as-f32.rs b/src/test/ui/numbers-arithmetic/u128-as-f32.rs
deleted file mode 100644
index 839ce932d..000000000
--- a/src/test/ui/numbers-arithmetic/u128-as-f32.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// run-pass
-
-#![feature(test)]
-#![deny(overflowing_literals)]
-extern crate test;
-
-use test::black_box;
-
-macro_rules! test {
- ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ({
- {
- const X: $src_ty = $val;
- const Y: $dest_ty = X as $dest_ty;
- assert_eq!(Y, $expected,
- "const eval {} -> {}", stringify!($src_ty), stringify!($dest_ty));
- }
- // black_box disables constant evaluation to test run-time conversions:
- assert_eq!(black_box::<$src_ty>($val) as $dest_ty, $expected,
- "run-time {} -> {}", stringify!($src_ty), stringify!($dest_ty));
- });
-}
-
-pub fn main() {
- // nextDown(f32::MAX) = 2^128 - 2 * 2^104
- const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.;
-
- // f32::MAX - 0.5 ULP and smaller should be rounded down
- test!(0xfffffe00000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
- test!(0xfffffe7fffffffffffffffffffffffff, u128 -> f32, SECOND_LARGEST_F32);
- test!(0xfffffe80000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
- // numbers within < 0.5 ULP of f32::MAX it should be rounded to f32::MAX
- test!(0xfffffe80000000000000000000000001, u128 -> f32, f32::MAX);
- test!(0xfffffeffffffffffffffffffffffffff, u128 -> f32, f32::MAX);
- test!(0xffffff00000000000000000000000000, u128 -> f32, f32::MAX);
- test!(0xffffff00000000000000000000000001, u128 -> f32, f32::MAX);
- test!(0xffffff7fffffffffffffffffffffffff, u128 -> f32, f32::MAX);
- // f32::MAX + 0.5 ULP and greater should be rounded to infinity
- test!(0xffffff80000000000000000000000000, u128 -> f32, f32::INFINITY);
- test!(0xffffff80000000f00000000000000000, u128 -> f32, f32::INFINITY);
- test!(0xffffff87ffffffffffffffff00000001, u128 -> f32, f32::INFINITY);
-
- // u128->f64 should not be affected by the u128->f32 checks
- test!(0xffffff80000000000000000000000000, u128 -> f64,
- 340282356779733661637539395458142568448.0);
- test!(u128::MAX, u128 -> f64, 340282366920938463463374607431768211455.0);
-}