Skip to content

Commit

Permalink
Merge pull request #265 from epage/float
Browse files Browse the repository at this point in the history
fix(ascii): Correctly parse 'infinity'
  • Loading branch information
epage authored Jun 29, 2023
2 parents 9ebd141 + c905623 commit 3d4b458
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ascii/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,8 @@ where
alt((
recognize_float,
crate::token::tag_no_case("nan"),
crate::token::tag_no_case("inf"),
crate::token::tag_no_case("infinity"),
crate::token::tag_no_case("inf"),
))
.parse_next(input)
}
Expand Down
9 changes: 6 additions & 3 deletions src/ascii/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,16 @@ mod complete {
}))
);

let (_i, nan) = float::<_, f32, ()>("NaN").unwrap();
let (i, nan) = float::<_, f32, ()>("NaN").unwrap();
assert!(nan.is_nan());
assert_eq!(i, "");

let (_i, inf) = float::<_, f32, ()>("inf").unwrap();
let (i, inf) = float::<_, f32, ()>("inf").unwrap();
assert!(inf.is_infinite());
let (_i, inf) = float::<_, f32, ()>("infinite").unwrap();
assert_eq!(i, "");
let (i, inf) = float::<_, f32, ()>("infinity").unwrap();
assert!(inf.is_infinite());
assert_eq!(i, "");
}

#[cfg(feature = "std")]
Expand Down

0 comments on commit 3d4b458

Please sign in to comment.