From dae6115d4de2f5f8de976adebbf3b725ed531f07 Mon Sep 17 00:00:00 2001 From: Sam Vente Date: Mon, 2 Oct 2023 19:12:08 +0200 Subject: [PATCH] add tests to str.nu (#627) As requested by @amtoine :yum: --------- Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com> --- stdlib-candidate/str.nu | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/stdlib-candidate/str.nu b/stdlib-candidate/str.nu index fe5a8d4..17f054a 100644 --- a/stdlib-candidate/str.nu +++ b/stdlib-candidate/str.nu @@ -6,6 +6,7 @@ def "str append" [tail: string]: [string -> string, list -> list _ => $input } } + def "str prepend" [head: string]: [string -> string, list -> list] { let input = $in match ($input | describe | str replace --regex '<.*' '') { @@ -14,3 +15,19 @@ def "str prepend" [head: string]: [string -> string, list -> list $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"] + +}