Relax whitespace rules for Infinity and NaN

Signed-off-by: Victor Porof <vporof@mozilla.com>
This commit is contained in:
Victor Porof 2017-02-04 08:45:02 +01:00
parent 00c99196a2
commit 419db388da
2 changed files with 6 additions and 2 deletions

View file

@ -32,10 +32,10 @@ pub nil -> Value =
"nil" { Value::Nil } "nil" { Value::Nil }
pub nan -> Value = pub nan -> Value =
"#f NaN" { Value::Float(OrderedFloat(NAN)) } "#f" __ "NaN" { Value::Float(OrderedFloat(NAN)) }
pub infinity -> Value = pub infinity -> Value =
"#f" s:$(sign) "Infinity" { "#f" __ s:$(sign) "Infinity" {
Value::Float(OrderedFloat(if s == "+" { INFINITY } else { NEG_INFINITY })) Value::Float(OrderedFloat(if s == "+" { INFINITY } else { NEG_INFINITY }))
} }

View file

@ -53,6 +53,7 @@ fn test_nil() {
#[test] #[test]
fn test_nan() { fn test_nan() {
assert_eq!(nan("#fNaN").unwrap(), Float(OrderedFloat(f64::NAN)));
assert_eq!(nan("#f NaN").unwrap(), Float(OrderedFloat(f64::NAN))); assert_eq!(nan("#f NaN").unwrap(), Float(OrderedFloat(f64::NAN)));
assert!(nan("true").is_err()); assert!(nan("true").is_err());
@ -63,6 +64,9 @@ fn test_infinity() {
assert_eq!(infinity("#f-Infinity").unwrap(), Float(OrderedFloat(f64::NEG_INFINITY))); assert_eq!(infinity("#f-Infinity").unwrap(), Float(OrderedFloat(f64::NEG_INFINITY)));
assert_eq!(infinity("#f+Infinity").unwrap(), Float(OrderedFloat(f64::INFINITY))); assert_eq!(infinity("#f+Infinity").unwrap(), Float(OrderedFloat(f64::INFINITY)));
assert_eq!(infinity("#f -Infinity").unwrap(), Float(OrderedFloat(f64::NEG_INFINITY)));
assert_eq!(infinity("#f +Infinity").unwrap(), Float(OrderedFloat(f64::INFINITY)));
assert!(infinity("true").is_err()); assert!(infinity("true").is_err());
} }