mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:45:50 +02:00
Bugfix/loss of precision when parsing value with unit (#15606)
Closes #12858 # Description As explained in the ticket, easy to reproduce. Example: 1.07 minute is 1.07*60=64.2 secondes ```nushell # before - wrong > 1.07min 1min 4sec # now - right > 1.07min 1min 4sec 200ms ``` # User-Facing Changes Bug is fixed when using ``into duration``. # Tests + Formatting Added a test for ``into duration`` Fixed ``parse_long_duration`` test: we gained precision 😄 # After Submitting Release notes? Or blog is enough? Let me know
This commit is contained in:
10
crates/nu-command/tests/commands/into_duration.rs
Normal file
10
crates/nu-command/tests/commands/into_duration.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
// Tests happy paths
|
||||
|
||||
#[test]
|
||||
fn into_duration_float() {
|
||||
let actual = nu!(r#"1.07min | into duration"#);
|
||||
|
||||
assert_eq!("1min 4sec 200ms", actual.out);
|
||||
}
|
@ -375,7 +375,7 @@ fn duration_decimal_math_with_nanoseconds() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1wk 3day 10ns");
|
||||
assert_eq!(actual.out, "1wk 3day 12hr 10ns");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -54,6 +54,7 @@ mod insert;
|
||||
mod inspect;
|
||||
mod interleave;
|
||||
mod into_datetime;
|
||||
mod into_duration;
|
||||
mod into_filesize;
|
||||
mod into_int;
|
||||
mod join;
|
||||
|
Reference in New Issue
Block a user