From af5d574d1f56ec07bb5495ca212323b11739f111 Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Tue, 26 Jan 2016 22:10:21 +0100 Subject: 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). --- src/libcoretest/num/dec2flt/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libcoretest') 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::(); +} + #[bench] fn bench_0(b: &mut test::Bencher) { b.iter(|| "0.0".parse::()); -- cgit 1.4.1-3-g733a5