diff --git a/src/parser.rs b/src/parser.rs index bd9b922..d90a1f0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -259,11 +259,11 @@ fn raw_string(input: &str) -> IResult<&str, &str, KdlParseError<&str>> { /// `number := decimal | hex | octal | binary` fn number(input: &str) -> IResult<&str, KdlValue, KdlParseError<&str>> { alt(( - map(integer, KdlValue::Int), map(hexadecimal, KdlValue::Int), map(octal, KdlValue::Int), map(binary, KdlValue::Int), map(float, KdlValue::Float), + map(integer, KdlValue::Int), ))(input) } diff --git a/tests/examples.rs b/tests/examples.rs index 95be07e..a8a5a52 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -57,6 +57,31 @@ macro_rules! nodes { () => { vec![] } } +const NUMBERS: &str = r#" +hex 0x32; +float 0.5; +binary 0b0110; +octal 0o755; +bignum 1_000_000; +scientific 1.234e-10; +"#; + +#[test] +fn test_numbers() { + let doc = parse_document(NUMBERS); + assert_eq!( + doc, + Ok(nodes! { + hex 0x32; + float 0.5; + binary 0b0110; + octal 0o755; + bignum 1_000_000; + scientific 1.234e-10; + }) + ); +} + #[test] fn test_ci() { let doc = parse_document(include_str!("../examples/ci.kdl"));