1
0
mirror of https://github.com/nushell/nushell.git synced 2025-08-13 13:57:45 +02:00
Files
.azureold
.cargo
.github
crates
nu-ansi-term
nu-cli
nu-color-config
nu-command
assets
src
tests
commands
hash_
keep
math
move_
path
random
skip
str_
all.rs
any.rs
append.rs
cal.rs
cd.rs
compact.rs
cp.rs
def.rs
default.rs
drop.rs
each.rs
echo.rs
empty.rs
enter.rs
every.rs
find.rs
first.rs
flatten.rs
format.rs
get.rs
group_by.rs
headers.rs
help.rs
histogram.rs
into_filesize.rs
into_int.rs
last.rs
length.rs
lines.rs
ls.rs
merge.rs
mkdir.rs
mod.rs
open.rs
parse.rs
prepend.rs
range.rs
reduce.rs
reject.rs
rename.rs
reverse.rs
rm.rs
roll.rs
rotate.rs
save.rs
select.rs
semicolon.rs
sort_by.rs
source.rs
split_by.rs
split_column.rs
split_row.rs
touch.rs
uniq.rs
update.rs
use_.rs
where_.rs
which.rs
with_env.rs
wrap.rs
zip.rs
format_conversions
main.rs
Cargo.toml
build.rs
nu-engine
nu-json
nu-parser
nu-path
nu-plugin
nu-pretty-hex
nu-protocol
nu-system
nu-table
nu-term-grid
nu-test-support
nu_plugin_chart
nu_plugin_example
nu_plugin_from_bson
nu_plugin_from_mp4
nu_plugin_from_sqlite
nu_plugin_gstat
nu_plugin_inc
nu_plugin_match
nu_plugin_python
nu_plugin_query
nu_plugin_s3
nu_plugin_start
nu_plugin_to_bson
nu_plugin_to_sqlite
nu_plugin_tree
README.md
docs
images
pkg_mgrs
samples
src
tests
wix
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
Cargo.toml.old
LICENSE
Makefile.toml
README.build.txt
README.md
extra_features_cargo_install.sh
rustfmt.toml
nushell/crates/nu-command/tests/commands/empty.rs
2022-02-07 14:54:06 -05:00

95 lines
2.3 KiB
Rust

use nu_test_support::{nu, pipeline};
// FIXME: jt: needs more work
#[ignore]
#[test]
fn reports_emptiness() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [[are_empty];
[([[check]; [[]] ])]
[([[check]; [""] ])]
[([[check]; [(wrap)] ])]
]
| get are_empty
| empty? check
| where check
| length
"#
));
assert_eq!(actual.out, "3");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn sets_block_run_value_for_an_empty_column() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [
[ first_name, last_name, rusty_at, likes ];
[ Andrés, Robalino, 10/11/2013, 1 ]
[ Jonathan, Turner, 10/12/2013, 1 ]
[ Jason, Gedge, 10/11/2013, 1 ]
[ Yehuda, Katz, 10/11/2013, '' ]
]
| empty? likes -b { 1 }
| get likes
| math sum
"#
));
assert_eq!(actual.out, "4");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn sets_block_run_value_for_many_empty_columns() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [
[ boost check ];
[ 1, [] ]
[ 1, "" ]
[ 1, (wrap) ]
]
| empty? boost check -b { 1 }
| get boost check
| math sum
"#
));
assert_eq!(actual.out, "6");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn passing_a_block_will_set_contents_on_empty_cells_and_leave_non_empty_ones_untouched() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [
[ NAME, LVL, HP ];
[ Andrés, 30, 3000 ]
[ Alistair, 29, 2900 ]
[ Arepas, "", "" ]
[ Jorge, 30, 3000 ]
]
| empty? LVL -b { 9 }
| empty? HP -b {
$it.LVL * 1000
}
| math sum
| get HP
"#
));
assert_eq!(actual.out, "17900");
}