mirror of
https://github.com/nushell/nushell.git
synced 2025-07-28 05:49:13 +02:00
.azure
.cargo
.circleci
.github
.theia
crates
nu-ansi-term
nu-cli
nu-command
assets
src
tests
commands
hash_
keep
math
avg.rs
eval.rs
median.rs
mod.rs
round.rs
sqrt.rs
sum.rs
move_
path
random
skip
str_
all.rs
any.rs
append.rs
cal.rs
cd.rs
compact.rs
config.rs
cp.rs
def.rs
default.rs
drop.rs
each.rs
echo.rs
empty.rs
enter.rs
every.rs
first.rs
flatten.rs
format.rs
get.rs
group_by.rs
headers.rs
help.rs
histogram.rs
insert.rs
into_int.rs
last.rs
length.rs
lines.rs
ls.rs
merge.rs
mkdir.rs
mod.rs
nth.rs
open.rs
parse.rs
prepend.rs
range.rs
reduce.rs
rename.rs
reverse.rs
rm.rs
roll.rs
rotate.rs
save.rs
select.rs
semicolon.rs
sort_by.rs
split_by.rs
split_column.rs
split_row.rs
touch.rs
uniq.rs
update.rs
where_.rs
which.rs
with_env.rs
wrap.rs
format_conversions
main.rs
Cargo.toml
README.md
build.rs
nu-completion
nu-data
nu-engine
nu-errors
nu-json
nu-parser
nu-path
nu-plugin
nu-pretty-hex
nu-protocol
nu-source
nu-stream
nu-table
nu-test-support
nu-value-ext
nu_plugin_binaryview
nu_plugin_chart
nu_plugin_fetch
nu_plugin_from_bson
nu_plugin_from_mp4
nu_plugin_from_sqlite
nu_plugin_inc
nu_plugin_match
nu_plugin_post
nu_plugin_ps
nu_plugin_query_json
nu_plugin_s3
nu_plugin_selector
nu_plugin_start
nu_plugin_sys
nu_plugin_textview
nu_plugin_to_bson
nu_plugin_to_sqlite
nu_plugin_tree
nu_plugin_xpath
README.md
debian
docker
docs
images
pkg_mgrs
samples
src
tests
wix
.dockerignore
.editorconfig
.gitignore
.gitpod.Dockerfile
.gitpod.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
Makefile.toml
README.build.txt
README.md
extra_features_cargo_install.sh
rustfmt.toml
* 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>
32 lines
690 B
Rust
32 lines
690 B
Rust
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");
|
|
}
|