diff --git a/crates/nu-utils/standard_library/std.nu b/crates/nu-utils/standard_library/std.nu index c73de3c997..898d30053b 100644 --- a/crates/nu-utils/standard_library/std.nu +++ b/crates/nu-utils/standard_library/std.nu @@ -199,47 +199,6 @@ export def "assert str contains" [left: string, right: string, message?: string] } } -# ```nushell -# >_ let branches = { -# ))) 1: { print "this is the 1st branch"} -# ))) 2: { print "this is the 2nd branch" } -# ))) 3: { print "this is the 3rd branch" } -# ))) 4: { print "this is the 4th branch" } -# ))) } -# -# >_ match 1 $branches -# ))) match 2 $branches -# ))) match 3 $branches -# ))) match 4 $branches -# ))) match 5 $branches -# this is the 1st branch -# this is the 2nd branch -# this is the 3rd branch -# this is the 4th branch -# -# >_ match 1 $branches { "this is the default branch" } -# ))) match 2 $branches { "this is the default branch" } -# ))) match 3 $branches { "this is the default branch" } -# ))) match 4 $branches { "this is the default branch" } -# ))) match 5 $branches { "this is the default branch" } -# this is the 1st branch -# this is the 2nd branch -# this is the 3rd branch -# this is the 4th branch -# this is the default branch -# ``` -export def match [ - input:string - matchers:record - default?: block -] { - if (($matchers | get -i $input) != null) { - $matchers | get $input | do $in - } else if ($default != null) { - do $default - } -} - # Add the given paths to the PATH. # # # Example diff --git a/crates/nu-utils/standard_library/test_std.nu b/crates/nu-utils/standard_library/test_std.nu index 6a49b796d1..f458f1cdb6 100644 --- a/crates/nu-utils/standard_library/test_std.nu +++ b/crates/nu-utils/standard_library/test_std.nu @@ -1,22 +1,5 @@ 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"