mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
Move std-rfc
into Nushell (#15042)
Move `std-rfc` into Nushell. `use std-rfc/<submodule>` now works "out-of-the-box"
This commit is contained in:
38
crates/nu-std/tests/test_std-rfc_path.nu
Normal file
38
crates/nu-std/tests/test_std-rfc_path.nu
Normal file
@ -0,0 +1,38 @@
|
||||
use std-rfc/path
|
||||
use std/assert
|
||||
|
||||
#[test]
|
||||
def path_with_extension [] {
|
||||
let new_path = "ab.txt" | path with-extension "rs"
|
||||
assert equal $new_path "ab.rs"
|
||||
|
||||
let new_path = "ab.txt" | path with-extension ".rs"
|
||||
assert equal $new_path "ab.rs"
|
||||
}
|
||||
|
||||
#[test]
|
||||
def path_with_extension_for_list [] {
|
||||
let new_path = ["ab.txt", "cd.exe"] | path with-extension "rs"
|
||||
assert equal $new_path ["ab.rs", "cd.rs"]
|
||||
|
||||
let new_path = ["ab.txt", "cd.exe"] | path with-extension ".rs"
|
||||
assert equal $new_path ["ab.rs", "cd.rs"]
|
||||
}
|
||||
|
||||
#[test]
|
||||
def path_with_stem [] {
|
||||
let new_path = $"(char psep)usr(char psep)bin" | path with-stem "share"
|
||||
assert equal $new_path $"(char psep)usr(char psep)share"
|
||||
|
||||
let new_path = [$"(char psep)home(char psep)alice(char psep)", $"(char psep)home(char psep)bob(char psep)secret.txt"] | path with-stem "nushell"
|
||||
assert equal $new_path [$"(char psep)home(char psep)nushell", $"(char psep)home(char psep)bob(char psep)nushell.txt"]
|
||||
}
|
||||
|
||||
#[test]
|
||||
def path_with_parent [] {
|
||||
let new_path = $"(char psep)etc(char psep)foobar" | path with-parent $"(char psep)usr(char psep)share(char psep)"
|
||||
assert equal $new_path $"(char psep)usr(char psep)share(char psep)foobar"
|
||||
|
||||
let new_path = [$"(char psep)home(char psep)rose(char psep)meow", $"(char psep)home(char psep)fdncred(char psep)"] | path with-parent $"(char psep)root(char psep)"
|
||||
assert equal $new_path [$"(char psep)root(char psep)meow", $"(char psep)root(char psep)fdncred"]
|
||||
}
|
Reference in New Issue
Block a user