From 247c43e9caa0fb8d356ee4f75d13ad400e1266e7 Mon Sep 17 00:00:00 2001 From: Bahex <17417311+Bahex@users.noreply.github.com> Date: Sat, 26 Apr 2025 18:01:37 +0300 Subject: [PATCH] test: add test cases for `one_of()` as function parameter --- tests/repl/test_signatures.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/repl/test_signatures.rs b/tests/repl/test_signatures.rs index 32de87d6c7..7ff5df4641 100644 --- a/tests/repl/test_signatures.rs +++ b/tests/repl/test_signatures.rs @@ -339,6 +339,36 @@ fn table_annotations_with_extra_characters() -> TestResult { fail_test(input, expected) } +#[rstest] +fn one_of_annotations( + #[values( + ("cell-path, list", "a.b.c", "cell-path"), + ("cell-path, list", "[a.b.c d.e.f]", "list"), + ("closure, any", "{}", "closure"), + ("closure, any", "{a: 1}", "record"), + )] + 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] #[case("{ |a $a }")] #[case("{ |a, b $a + $b }")]