Math#media - ability to compute median value.

This commit is contained in:
Andrés N. Robalino
2020-06-18 16:37:18 -05:00
parent 353b33be1b
commit 5f9de80d9b
10 changed files with 266 additions and 22 deletions

View File

@ -0,0 +1,29 @@
use nu_test_support::{nu, pipeline};
#[test]
fn median_numbers_with_even_rows() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [10 6 19 21 4]
| math median
| echo $it
"#
));
assert_eq!(actual.out, "10")
}
#[test]
fn median_numbers_with_odd_rows() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [3 8 9 12 12 15]
| math median
| echo $it
"#
));
assert_eq!(actual.out, "10.5")
}