mirror of
https://github.com/nushell/nushell.git
synced 2025-07-15 22:05:51 +02:00
.cargo
.githooks
.github
assets
benches
crates
nu-cli
nu-cmd-base
nu-cmd-dataframe
nu-cmd-extra
nu-cmd-lang
nu-color-config
nu-command
src
tests
commands
assignment
conversions
database
date
hash_
math
move_
network
path
basename.rs
dirname.rs
exists.rs
expand.rs
join.rs
mod.rs
parse.rs
split.rs
type_.rs
platform
query
random
skip
str_
take
url
alias.rs
all.rs
any.rs
append.rs
break_.rs
cal.rs
cd.rs
compact.rs
complete.rs
config_env_default.rs
config_nu_default.rs
continue_.rs
cp.rs
debug_info.rs
def.rs
default.rs
detect_columns.rs
do_.rs
drop.rs
du.rs
each.rs
echo.rs
empty.rs
error_make.rs
every.rs
exec.rs
export_def.rs
fill.rs
find.rs
first.rs
flatten.rs
for_.rs
format.rs
generate.rs
get.rs
glob.rs
group_by.rs
headers.rs
help.rs
histogram.rs
ignore.rs
insert.rs
inspect.rs
interleave.rs
into_datetime.rs
into_filesize.rs
into_int.rs
join.rs
last.rs
length.rs
let_.rs
lines.rs
loop_.rs
ls.rs
match_.rs
merge.rs
mktemp.rs
mod.rs
mut_.rs
nu_check.rs
open.rs
par_each.rs
parse.rs
prepend.rs
print.rs
range.rs
redirection.rs
reduce.rs
reject.rs
rename.rs
return_.rs
reverse.rs
rm.rs
roll.rs
rotate.rs
run_external.rs
save.rs
select.rs
semicolon.rs
seq.rs
seq_char.rs
seq_date.rs
sort.rs
sort_by.rs
source_env.rs
split_by.rs
split_column.rs
split_row.rs
table.rs
tee.rs
terminal.rs
to_text.rs
touch.rs
transpose.rs
try_.rs
ucp.rs
ulimit.rs
umkdir.rs
uniq.rs
uniq_by.rs
update.rs
upsert.rs
use_.rs
where_.rs
which.rs
while_.rs
with_env.rs
wrap.rs
zip.rs
format_conversions
main.rs
Cargo.toml
LICENSE
nu-engine
nu-explore
nu-glob
nu-json
nu-lsp
nu-parser
nu-path
nu-plugin
nu-pretty-hex
nu-protocol
nu-std
nu-system
nu-table
nu-term-grid
nu-test-support
nu-utils
nu_plugin_custom_values
nu_plugin_example
nu_plugin_formats
nu_plugin_gstat
nu_plugin_inc
nu_plugin_python
nu_plugin_query
nu_plugin_stream_example
README.md
devdocs
docker
scripts
src
tests
wix
.gitattributes
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
Cross.toml
LICENSE
README.md
rust-toolchain.toml
toolkit.nu
typos.toml
90 lines
1.8 KiB
Rust
90 lines
1.8 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
use super::join_path_sep;
|
|
|
|
#[test]
|
|
fn returns_basename_of_empty_input() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo ""
|
|
| path basename
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn replaces_basename_of_empty_input() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo ""
|
|
| path basename --replace newname.txt
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "newname.txt");
|
|
}
|
|
|
|
#[test]
|
|
fn returns_basename_of_path_ending_with_dot() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo "some/file.txt/."
|
|
| path basename
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "file.txt");
|
|
}
|
|
|
|
#[test]
|
|
fn replaces_basename_of_path_ending_with_dot() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo "some/file.txt/."
|
|
| path basename --replace viking.txt
|
|
"#
|
|
));
|
|
|
|
let expected = join_path_sep(&["some", "viking.txt"]);
|
|
assert_eq!(actual.out, expected);
|
|
}
|
|
|
|
#[test]
|
|
fn returns_basename_of_path_ending_with_double_dot() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo "some/file.txt/.."
|
|
| path basename
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn replaces_basename_of_path_ending_with_double_dot() {
|
|
let actual = nu!(
|
|
cwd: "tests", pipeline(
|
|
r#"
|
|
echo "some/file.txt/.."
|
|
| path basename --replace eggs
|
|
"#
|
|
));
|
|
|
|
let expected = join_path_sep(&["some/file.txt/..", "eggs"]);
|
|
assert_eq!(actual.out, expected);
|
|
}
|
|
|
|
#[test]
|
|
fn const_path_basename() {
|
|
let actual = nu!("const name = ('spam/eggs.txt' | path basename); $name");
|
|
assert_eq!(actual.out, "eggs.txt");
|
|
}
|