mirror of
https://github.com/nushell/nushell.git
synced 2025-05-19 09:20:45 +02:00
test: add test cases for one_of()
as function parameter
This commit is contained in:
parent
ec2b9769c9
commit
247c43e9ca
@ -339,6 +339,36 @@ fn table_annotations_with_extra_characters() -> TestResult {
|
|||||||
fail_test(input, expected)
|
fail_test(input, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
fn one_of_annotations(
|
||||||
|
#[values(
|
||||||
|
("cell-path, list<cell-path>", "a.b.c", "cell-path"),
|
||||||
|
("cell-path, list<cell-path>", "[a.b.c d.e.f]", "list<cell-path>"),
|
||||||
|
("closure, any", "{}", "closure"),
|
||||||
|
("closure, any", "{a: 1}", "record<a: int>"),
|
||||||
|
)]
|
||||||
|
annotation_data: (&str, &str, &str),
|
||||||
|
) -> TestResult {
|
||||||
|
let (types, argument, expected) = annotation_data;
|
||||||
|
|
||||||
|
let input = format!("def run [t: one_of({types})] {{ $t }}; run {argument} | describe");
|
||||||
|
run_test(&input, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn one_of_annotations_not_terminated() -> TestResult {
|
||||||
|
let input = "def run [t: one_of(binary, string] { $t }";
|
||||||
|
let expected = "expected closing )";
|
||||||
|
fail_test(input, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn one_of_annotations_with_extra_characters() -> TestResult {
|
||||||
|
let input = "def run [t: one_of(int, string)extra] {$t}";
|
||||||
|
let expected = "Extra characters in the parameter name";
|
||||||
|
fail_test(input, expected)
|
||||||
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case("{ |a $a }")]
|
#[case("{ |a $a }")]
|
||||||
#[case("{ |a, b $a + $b }")]
|
#[case("{ |a, b $a + $b }")]
|
||||||
|
Loading…
Reference in New Issue
Block a user