nushell/crates/nu-utils/standard_library/test_std.nu
Máté FARKAS 7d963776a0
stdlib: Implement common assert commands (#8515)
Implement common assert commands with tests.
Fixes #8419.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-20 08:57:28 -05:00

42 lines
1008 B
Plaintext

use std.nu
export def test_match [] {
use std.nu assert
let branches = {
1: {|| -1 }
2: {|| -2 }
}
assert ((std match 1 $branches) == -1)
assert ((std match 2 $branches) == -2)
assert ((std match 3 $branches) == $nothing)
assert ((std match 1 $branches { 0 }) == -1)
assert ((std match 2 $branches { 0 }) == -2)
assert ((std match 3 $branches { 0 }) == 0)
}
export def test_path_add [] {
use std.nu "assert equal"
with-env [PATH []] {
assert equal $env.PATH []
std path add "/foo/"
assert equal $env.PATH ["/foo/"]
std path add "/bar/" "/baz/"
assert equal $env.PATH ["/bar/", "/baz/", "/foo/"]
let-env PATH = []
std path add "foo"
std path add "bar" "baz" --append
assert equal $env.PATH ["foo", "bar", "baz"]
assert equal (std path add "fooooo" --ret) ["fooooo", "foo", "bar", "baz"]
assert equal $env.PATH ["fooooo", "foo", "bar", "baz"]
}
}