diff options
author | Rob Landley <rob@landley.net> | 2016-03-16 12:33:32 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-03-16 12:33:32 -0500 |
commit | 1af3bad8b63b2b6886123d9e681782781a62efca (patch) | |
tree | d90be779f6ddf206141204f1e0582463fe0c2441 /tests/expr.test | |
parent | e6912f90d663120b32b894d1f10a0d8cd530e2e7 (diff) | |
download | toybox-1af3bad8b63b2b6886123d9e681782781a62efca.tar.gz |
Move whitespace and curly brackets around, move reference URLs to top of file,
eliminate syntax_error() function (just call error_exit() directly),
eliminate advance() wrapper, pipe expected error messages in test to /dev/null
Diffstat (limited to 'tests/expr.test')
-rwxr-xr-x | tests/expr.test | 22 |
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" "" "" |