about summary refs log tree commit diff
path: root/example/std_example.rs
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-08-21 14:35:48 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2019-08-21 14:35:48 +0200
commit1f90b04cd6cd492260a5e4230da6128037b5461b (patch)
treefc9d6ba5d80646a1a17edc98953c81c156e02d30 /example/std_example.rs
parentb2d6705fe2e7eb51e3d3cf7421da8513ad1e948e (diff)
downloadrust-1f90b04cd6cd492260a5e4230da6128037b5461b.tar.gz
rust-1f90b04cd6cd492260a5e4230da6128037b5461b.zip
Fix float -> u/i128 cast
The original test casts were optimized away by rustc,
so cg_clif never saw them.

cc #668
Diffstat (limited to 'example/std_example.rs')
-rw-r--r--example/std_example.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/example/std_example.rs b/example/std_example.rs
index 14a9a567d42..71b2a34b61d 100644
--- a/example/std_example.rs
+++ b/example/std_example.rs
@@ -56,15 +56,18 @@ fn main() {
     assert_eq!(353985398u128 * 932490u128, 330087843781020u128);
 
     // Check that all u/i128 <-> float casts work correctly.
-    assert_eq!(100u128 as f32, 100.0);
-    assert_eq!(100u128 as f64, 100.0);
-    assert_eq!(100.0f32 as u128, 100);
-    assert_eq!(100.0f64 as u128, 100);
-    assert_eq!(100i128 as f32, 100.0);
-    assert_eq!(100i128 as f64, 100.0);
-    assert_eq!(100.0f32 as i128, 100);
-    assert_eq!(100.0f64 as i128, 100);
-
+    let houndred_u128 = 100u128;
+    let houndred_i128 = 100i128;
+    let houndred_f32 = 100.0f32;
+    let houndred_f64 = 100.0f64;
+    assert_eq!(houndred_u128 as f32, 100.0);
+    assert_eq!(houndred_u128 as f64, 100.0);
+    assert_eq!(houndred_f32 as u128, 100);
+    assert_eq!(houndred_f64 as u128, 100);
+    assert_eq!(houndred_i128 as f32, 100.0);
+    assert_eq!(houndred_i128 as f64, 100.0);
+    assert_eq!(houndred_f32 as i128, 100);
+    assert_eq!(houndred_f64 as i128, 100);
 
     let _a = 1u32 << 2u8;