From f6880bff8f5faca21a2e420261d0aac258ac9eb7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 14 Oct 2023 14:58:41 +0200 Subject: [PATCH] expr: test some invalid syntaxes --- tests/by-util/test_expr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 1064ef525ee..3f403c7ea37 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -275,3 +275,16 @@ fn test_invalid_substr() { .code_is(1) .stdout_only("\n"); } + +#[test] +fn test_invalid_syntax() { + let invalid_syntaxes = [["12", "12"], ["12", "|"], ["|", "12"]]; + + for invalid_syntax in invalid_syntaxes { + new_ucmd!() + .args(&invalid_syntax) + .fails() + .code_is(2) + .stderr_contains("syntax error"); + } +}