1
Fork 0
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:
Sam Vente 2023-10-02 19:12:08 +02:00 committed by GitHub
parent 150105f93f
commit dae6115d4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"]
}