mirror of
https://github.com/nushell/nushell.git
synced 2024-12-11 17:51:50 +01:00
a042f407c1
* Converting average.rs to math.rs * Making some progress towards math Examples and unit tests failing, also think I found a bug with passing in strings * Fix typos * Found issue with negative numbers * Add some comments * Split commands like in split and str_ but do not register? * register commands in cli * Address clippy warnings * Fix bad examples * Make the example failure message more helpful * Replace unwraps * Use compare_values to avoid coercion issues * Remove unneeded code
27 lines
653 B
Rust
27 lines
653 B
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn can_average_numbers() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open sgml_description.json
|
|
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
|
| math average
|
|
| echo $it
|
|
"#
|
|
));
|
|
println!("{:?}", actual.err);
|
|
assert_eq!(actual.out, "101.5")
|
|
}
|
|
|
|
#[test]
|
|
fn can_average_bytes() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats",
|
|
"ls | sort-by name | skip 1 | first 2 | get size | math average | format \"{$it}\" | echo $it"
|
|
);
|
|
|
|
assert_eq!(actual.out, "1.6 KB");
|
|
}
|