From: jca Date: Fri, 12 Jan 2018 11:13:29 +0000 (+0000) Subject: Add basic tests for octal and hex notation in arithmetic expansions X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=09bb800c703a6a5683fda0d36c76e46a08e1d4d0;p=openbsd Add basic tests for octal and hex notation in arithmetic expansions POSIX requires only decimal, octal and hex, tests for the $((x#number)) notation could be useful too. --- diff --git a/regress/bin/ksh/arith.t b/regress/bin/ksh/arith.t index e18ea2e9d78..888909eba2d 100644 --- a/regress/bin/ksh/arith.t +++ b/regress/bin/ksh/arith.t @@ -77,3 +77,47 @@ expected-stdout: 6,5,3 --- +name: check-octal-valid-1 +description: + Check octal notation (valid input) +stdin: + echo $((00)),$((-00)),$((007)),$((-007)),$((010)),$((-010)) + echo $((010 + 1)) +expected-stdout: + 0,0,7,-7,8,-8 + 9 + +--- + +name: check-octal-invalid-1 +description: + Check octal notation (invalid input) +stdin: + echo $((08)) +expected-exit: e != 0 +expected-stderr-pattern: + /.*:.*08.*bad number/ + +--- +name: check-hex-valid-1 +description: + Check hex notation (valid input) +stdin: + echo $((0x0)),$((-0x0)),$((0xf)),$((-0xf)),$((0x10)),$((-0x10)) + echo $((0x10 + 1)) +expected-stdout: + 0,0,15,-15,16,-16 + 17 + +--- + +name: check-hex-invalid-1 +description: + Check hex notation (invalid input) +stdin: + echo $((0xg)) +expected-exit: e != 0 +expected-stderr-pattern: + /.*:.* 0xg.*bad number/ + +---