summaryrefslogtreecommitdiff
path: root/regress/bin
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2018-01-12 11:13:30 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2018-01-12 11:13:30 +0000
commit368e74e1ddc5a58bb04deaaaf98cf140948070f7 (patch)
treed96fcd78ed2da82552cdec41c5a33dc76a5891da /regress/bin
parent08ba2aadb6c8d77a1f892dc8c0293d54a67a7442 (diff)
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.
Diffstat (limited to 'regress/bin')
-rw-r--r--regress/bin/ksh/arith.t44
1 files changed, 44 insertions, 0 deletions
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/
+
+---