aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/expr.test22
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/expr.test b/tests/expr.test
index 19db19eb..c6dc261b 100755
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -19,8 +19,8 @@ testing "* % same priority" "expr 3 \* 2 % 4" "2\n" "" ""
testing "= > same priority" "expr 0 = 2 \> 3" "0\n" "" ""
testing "> = same priority" "expr 3 \> 2 = 1" "1\n" "" ""
-testing "/ by zero" "expr 1 / 0; echo \$?" "2\n" "" ""
-testing "% by zero" "expr 1 % 0; echo \$?" "2\n" "" ""
+testing "/ by zero" "expr 1 / 0 2>/dev/null; echo \$?" "2\n" "" ""
+testing "% by zero" "expr 1 % 0 2>/dev/null; echo \$?" "2\n" "" ""
testing "regex position" "expr ab21xx : '[^0-9]*[0-9]*'" "4\n" "" ""
testing "regex extraction" "expr ab21xx : '[^0-9]*\([0-9]*\).*'" "21\n" "" ""
@@ -41,17 +41,19 @@ testing "parens around literal" "expr \( a \)" "a\n" "" ""
testing "exit code when true" "expr a; echo \$?" "a\n0\n" "" ""
testing "exit code when false" "expr 0; echo \$?" "0\n1\n" "" ""
-testing "exit code with syntax error" "expr \(; echo \$?" "2\n" "" ""
+testing "exit code with syntax error" "expr \( 2>/dev/null; echo \$?" \
+ "2\n" "" ""
testing "exit code when evaluating to 0" "expr -1 + 1; echo \$?" "0\n1\n" "" ""
# BUG: segfaults because '3' is coerced to integer and regexc gets NULL
testing "regex segfault" "expr 3 : '\(.\)'" "3\n" "" ""
# syntax errors
-testing "no expression" "expr; echo \$?" "2\n" "" ""
-testing "empty ()" "expr \( \); echo \$?" "2\n" "" ""
-testing "missing )" "expr \( 1; echo \$?" "2\n" "" ""
-testing "missing outer )" "expr \( 1 + \( 2 \* 3 \); echo \$?" "2\n" "" ""
-testing "bad operator" "expr 1 @ 2; echo \$?" "2\n" "" ""
-testing "adjacent literals" "expr 1 2; echo \$?" "2\n" "" ""
-testing "non-integer argument" "expr 1 + a; echo \$?" "2\n" "" ""
+testing "no expression" "expr 2>/dev/null; echo \$?" "2\n" "" ""
+testing "empty ()" "expr \( \) 2>/dev/null; echo \$?" "2\n" "" ""
+testing "missing )" "expr \( 1 2>/dev/null; echo \$?" "2\n" "" ""
+testing "missing outer )" "expr \( 1 + \( 2 \* 3 \) 2>/dev/null; echo \$?" \
+ "2\n" "" ""
+testing "bad operator" "expr 1 @ 2 2>/dev/null; echo \$?" "2\n" "" ""
+testing "adjacent literals" "expr 1 2 2>/dev/null; echo \$?" "2\n" "" ""
+testing "non-integer argument" "expr 1 + a 2>/dev/null; echo \$?" "2\n" "" ""