1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00
nu_scripts/stdlib-candidate-archive/tests/path.nu
Douglas 5869e0b529
Deprecate the nu_scripts version of stdlib-candidate (#1042)
Deprecates the existing `stdlib-candidate` directories in `nu_scripts`
since `std-rfc` has now transitioned to the main repo. Updates readme
and renamed directories.
2025-02-09 14:34:40 -06:00

39 lines
1.1 KiB
Text

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 = "/usr/bin" | path with-stem "share"
assert equal $new_path "/usr/share"
let new_path = ["/home/alice/", "/home/bob/secret.txt"] | path with-stem "nushell"
assert equal $new_path ["/home/nushell", "/home/bob/nushell.txt"]
}
#[test]
def path_with_parent [] {
let new_path = "/etc/foobar" | path with-parent "/usr/share/"
assert equal $new_path "/usr/share/foobar"
let new_path = ["/home/rose/meow", "/home/fdncred/"] | path with-parent "/root/"
assert equal $new_path ["/root/meow", "/root/fdncred"]
}