mirror of
https://github.com/nushell/nushell.git
synced 2025-07-02 23:51:49 +02:00
nu-parser + nu-protocol: switch to metric for KB, MB, GB, add KiB, MiB, GiB units (#3035)
fixes inconsistency with formatting/rendering which uses standard Rust byte_unit https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
This commit is contained in:
@ -31,11 +31,18 @@ impl WholeStreamCommand for IntoInt {
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kb | each { = $it / 1024 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
}]
|
||||
vec![
|
||||
Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kb | each { = $it / 1000 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
},
|
||||
Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kib | each { = $it / 1024 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,19 @@ fn into_int_filesize() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
into-int 1kb | each {= $it / 1024 }
|
||||
into-int 1kb | each {= $it / 1000 }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains('1'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_int_filesize2() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
into-int 1kib | each {= $it / 1024 }
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -7,7 +7,7 @@ use nu_test_support::pipeline;
|
||||
fn filters_by_unit_size_comparison() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | where size > 1kb | sort-by size | get name | first 1 | str trim"
|
||||
"ls | where size > 1kib | sort-by size | get name | first 1 | str trim"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "cargo_sample.toml");
|
||||
|
Reference in New Issue
Block a user