diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-02-21 19:33:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-02-21 19:33:33 +0000 |
commit | d4edabf1ee1c8b991e19b50dc60323676569ea2d (patch) | |
tree | b2f01f2341f8ba14212740997d12882793b39146 /regress | |
parent | 3b1192555695f84bf2dd46bcc245d843c0827303 (diff) |
a handful of new tests related to expr.c rev. 1.34
Diffstat (limited to 'regress')
-rw-r--r-- | regress/bin/ksh/arith.t | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/regress/bin/ksh/arith.t b/regress/bin/ksh/arith.t index 888909eba2d..087d11e9e02 100644 --- a/regress/bin/ksh/arith.t +++ b/regress/bin/ksh/arith.t @@ -121,3 +121,66 @@ expected-stderr-pattern: /.*:.* 0xg.*bad number/ --- + +name: arith-recurse-1 +description: + Check that arithmetic evaluation substitutes integer values + of variables recursively. +stdin: + vb=va + va=42 + echo $((vb)) +expected-stdout: + 42 + +--- + +name: arith-recurse-2 +description: + Check that variables can be used as array indices. +stdin: + vb='aa[va]' + set -A aa 40 41 42 43 + va=2 + echo ${aa[va]} + echo ${aa[$va]} + echo $((aa[va])) + echo $((aa[$va])) + echo $((vb)) +expected-stdout: + 42 + 42 + 42 + 42 + 42 + +--- + +name: arith-subst-1 +description: + Check that arithmetic evaluation does not apply parameter + substitution to the values of variables. +stdin: + va=17 + vb='$va' + echo $((vb)) +expected-exit: e != 0 +expected-stderr-pattern: + /.*:.*\$va.*unexpected.*\$/ + +--- + +name: arith-subst-2 +description: + Check that arithmetic evaluation does not apply parameter + substitution to arry indices inside the values of variables. +stdin: + set -A aa 40 41 42 43 + va=2 + vb='aa[$va]' + echo $((vb)) +expected-exit: e != 0 +expected-stderr-pattern: + /.*:.*\$va.*unexpected.*\$/ + +--- |