xref: /freebsd/bin/sh/tests/expansion/arith10.0 (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
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