Skip to content

Commit 67daa4c

Browse files
authored
Fix a test about float parser (#32)
See rust-lang/rust#48235
1 parent 4a30fb3 commit 67daa4c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ecmascript/parser/src/lexer/number.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ mod tests {
355355
/// Valid even on strict mode.
356356
const VALID_CASES: &[&str] = &[".0", "0.e-1", "0e8", ".8e1", "0.8e1", "1.18e1"];
357357
const INVALID_CASES_ON_STRICT: &[&str] = &["08e1", "08.1", "08.8e1", "08", "01"];
358-
const INVALID_CASES: &[&str] = &[".e-1", "01.8e1", "012e1", "00e1", "00.0"];
358+
const INVALID_CASES: &[&str] = &["01.8e1", "012e1", "00e1", "00.0"];
359359

360360
fn test_floats(strict: bool, success: bool, cases: &'static [&'static str]) {
361361
for case in cases {
@@ -367,7 +367,12 @@ mod tests {
367367
let expected: f64 = (i64::from_str_radix(case, 8).map(|v| v as f64))
368368
.or_else(|_| case.parse::<i64>().map(|v| v as f64))
369369
.or_else(|_| case.parse::<f64>())
370-
.expect("failed to parse `expected` as float using str.parse()");
370+
.unwrap_or_else(|err| {
371+
panic!(
372+
"failed to parse '{}' as float using str.parse(): {}",
373+
case, err
374+
)
375+
});
371376

372377
let vec = panic::catch_unwind(|| {
373378
::with_test_sess(case, |mut sess, input| {

0 commit comments

Comments
 (0)