Parse decimal units (#3243)

* parse decimal units

* linting

* stop clippy complaining

* Added tests to parsing decimals

* Fixed bug

* Fixed testing and add more
This commit is contained in:
Luccas Mateus
2021-04-03 05:06:13 -03:00
committed by GitHub
parent e737222a5d
commit 2146ede15d
2 changed files with 176 additions and 41 deletions

View File

@ -187,6 +187,18 @@ fn duration_math() {
assert_eq!(actual.out, "8day");
}
#[test]
fn duration_decimal_math() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
= 0.5mon + 1day
"#
));
assert_eq!(actual.out, "16day");
}
#[test]
fn duration_math_with_nanoseconds() {
let actual = nu!(
@ -199,6 +211,18 @@ fn duration_math_with_nanoseconds() {
assert_eq!(actual.out, "7day 10ns");
}
#[test]
fn duration_decimal_math_with_nanoseconds() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
= 1.5wk + 10ns
"#
));
assert_eq!(actual.out, "10day 10ns");
}
#[test]
fn duration_math_with_negative() {
let actual = nu!(