summary refs log tree commit diff
path: root/src/libcoretest
diff options
context:
space:
mode:
authorRobin Kruppe <robin.kruppe@gmail.com>2016-01-26 22:10:21 +0100
committerRobin Kruppe <robin.kruppe@gmail.com>2016-02-04 16:28:06 +0100
commitaf5d574d1f56ec07bb5495ca212323b11739f111 (patch)
tree5febe44f8de7b6565543ffff74de13ee3a2cd5dd /src/libcoretest
parenta8dc1f974be05b80b2edf17b62eee47e38edf2de (diff)
downloadrust-af5d574d1f56ec07bb5495ca212323b11739f111.tar.gz
rust-af5d574d1f56ec07bb5495ca212323b11739f111.zip
Prevent the immediate panic uncovered by #31109 and add a test.
The code there still triggers an ICE, but for different reasons (const eval unwraps the parse result).
Diffstat (limited to 'src/libcoretest')
-rw-r--r--src/libcoretest/num/dec2flt/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcoretest/num/dec2flt/mod.rs b/src/libcoretest/num/dec2flt/mod.rs
index 7b25333e21e..a96c2957568 100644
--- a/src/libcoretest/num/dec2flt/mod.rs
+++ b/src/libcoretest/num/dec2flt/mod.rs
@@ -136,6 +136,17 @@ fn massive_exponent() {
     assert_eq!(format!("1e{}000", max).parse(), Ok(f64::INFINITY));
 }
 
+#[test]
+fn borderline_overflow() {
+    let mut s = "0.".to_string();
+    for _ in 0..375 {
+        s.push('3');
+    }
+    // At the time of this writing, this returns Err(..), but this is a bug that should be fixed.
+    // It makes no sense to enshrine that in a test, the important part is that it doesn't panic.
+    let _ = s.parse::<f64>();
+}
+
 #[bench]
 fn bench_0(b: &mut test::Bencher) {
     b.iter(|| "0.0".parse::<f64>());