xref: /freebsd/bin/sh/tests/expansion/arith10.0 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1
2failures=0
3
4check() {
5	if [ $(($1)) != $2 ]; then
6		failures=$((failures+1))
7		echo "For $1, expected $2 actual $(($1))"
8	fi
9}
10
11readonly ro=4
12rw=1
13check "0 && 0 / 0" 0
14check "1 || 0 / 0" 1
15check "0 && (ro = 2)" 0
16check "ro" 4
17check "1 || (ro = -1)" 1
18check "ro" 4
19check "0 && (rw += 1)" 0
20check "rw" 1
21check "1 || (rw += 1)" 1
22check "rw" 1
23check "0 ? 44 / 0 : 51" 51
24check "0 ? ro = 3 : 52" 52
25check "ro" 4
26check "0 ? rw += 1 : 52" 52
27check "rw" 1
28check "1 ? 68 : 30 / 0" 68
29check "2 ? 1 : (ro += 2)" 1
30check "ro" 4
31check "4 ? 1 : (rw += 1)" 1
32check "rw" 1
33
34exit $((failures != 0))
35