]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/expansion/arith10.0
shell_cmds-203.tar.gz
[apple/shell_cmds.git] / sh / tests / expansion / arith10.0
1 # $FreeBSD: head/bin/sh/tests/expansion/arith10.0 218469 2011-02-08 23:23:55Z jilles $
2
3 failures=0
4
5 check() {
6 if [ $(($1)) != $2 ]; then
7 failures=$((failures+1))
8 echo "For $1, expected $2 actual $(($1))"
9 fi
10 }
11
12 readonly ro=4
13 rw=1
14 check "0 && 0 / 0" 0
15 check "1 || 0 / 0" 1
16 check "0 && (ro = 2)" 0
17 check "ro" 4
18 check "1 || (ro = -1)" 1
19 check "ro" 4
20 check "0 && (rw += 1)" 0
21 check "rw" 1
22 check "1 || (rw += 1)" 1
23 check "rw" 1
24 check "0 ? 44 / 0 : 51" 51
25 check "0 ? ro = 3 : 52" 52
26 check "ro" 4
27 check "0 ? rw += 1 : 52" 52
28 check "rw" 1
29 check "1 ? 68 : 30 / 0" 68
30 check "2 ? 1 : (ro += 2)" 1
31 check "ro" 4
32 check "4 ? 1 : (rw += 1)" 1
33 check "rw" 1
34
35 exit $((failures != 0))