mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Mathsqrt (#3239)
* Output error when ls into a file without permission * math sqrt * added test to check fails when ls into prohibited dir * fix lint * math sqrt with tests and doc * trigger wasm build * Update filesystem_shell.rs * always forgetting the linting * fix clippy complaining Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
This commit is contained in:
@ -2,6 +2,7 @@ mod avg;
|
||||
mod eval;
|
||||
mod median;
|
||||
mod round;
|
||||
mod sqrt;
|
||||
mod sum;
|
||||
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
31
crates/nu-command/tests/commands/math/sqrt.rs
Normal file
31
crates/nu-command/tests/commands/math/sqrt.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn can_sqrt_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo [0.25 2 4] | math sqrt | math sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "3.914213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_sqrt_irrational() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 2 | math sqrt"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_sqrt_perfect_square() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"echo 4 | math sqrt"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
}
|
Reference in New Issue
Block a user