mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:35:59 +02:00
Math#media - ability to compute median value.
This commit is contained in:
@ -11,7 +11,7 @@ fn can_average_numbers() {
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
println!("{:?}", actual.err);
|
||||
|
||||
assert_eq!(actual.out, "101.5")
|
||||
}
|
||||
|
29
crates/nu-cli/tests/commands/math/median.rs
Normal file
29
crates/nu-cli/tests/commands/math/median.rs
Normal 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")
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
mod average;
|
||||
mod median;
|
||||
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
@ -1,6 +1,5 @@
|
||||
mod alias;
|
||||
mod append;
|
||||
mod average;
|
||||
mod cal;
|
||||
mod calc;
|
||||
mod cd;
|
||||
|
Reference in New Issue
Block a user