mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
add tests to str.nu (#627)
As requested by @amtoine 😋
---------
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
This commit is contained in:
parent
150105f93f
commit
dae6115d4d
1 changed files with 17 additions and 0 deletions
|
@ -6,6 +6,7 @@ def "str append" [tail: string]: [string -> string, list<string> -> list<string>
|
|||
_ => $input
|
||||
}
|
||||
}
|
||||
|
||||
def "str prepend" [head: string]: [string -> string, list<string> -> list<string>] {
|
||||
let input = $in
|
||||
match ($input | describe | str replace --regex '<.*' '') {
|
||||
|
@ -14,3 +15,19 @@ def "str prepend" [head: string]: [string -> string, list<string> -> list<string
|
|||
_ => $input
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
def test_append [] {
|
||||
use std assert
|
||||
assert equal ("foo" | str append "/") "foo/"
|
||||
assert equal (["foo", "bar", "baz"] | str append "/") ["foo/", "bar/", "baz/"]
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
def test_prepend [] {
|
||||
use std assert
|
||||
assert equal ("foo" | str prepend "/") "/foo"
|
||||
assert equal (["foo", "bar", "baz"] | str prepend "/") ["/foo", "/bar", "/baz"]
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue