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