1882-Add min, max in addition to average for acting lists (#1969)

* 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
This commit is contained in:
Arash Outadi
2020-06-13 14:49:57 -07:00
committed by GitHub
parent 40673e4599
commit a042f407c1
12 changed files with 440 additions and 79 deletions

View File

@ -7,11 +7,11 @@ fn can_average_numbers() {
r#"
open sgml_description.json
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
| average
| math average
| echo $it
"#
));
println!("{:?}", actual.err);
assert_eq!(actual.out, "101.5")
}
@ -19,7 +19,7 @@ fn can_average_numbers() {
fn can_average_bytes() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | sort-by name | skip 1 | first 2 | get size | average | format \"{$it}\" | echo $it"
"ls | sort-by name | skip 1 | first 2 | get size | math average | format \"{$it}\" | echo $it"
);
assert_eq!(actual.out, "1.6 KB");