arith10.0 revision 218469
1218469Sjilles# $FreeBSD: head/tools/regression/bin/sh/expansion/arith10.0 218469 2011-02-08 23:23:55Z jilles $ 2218469Sjilles 3218469Sjillesfailures=0 4218469Sjilles 5218469Sjillescheck() { 6218469Sjilles if [ $(($1)) != $2 ]; then 7218469Sjilles failures=$((failures+1)) 8218469Sjilles echo "For $1, expected $2 actual $(($1))" 9218469Sjilles fi 10218469Sjilles} 11218469Sjilles 12218469Sjillesreadonly ro=4 13218469Sjillesrw=1 14218469Sjillescheck "0 && 0 / 0" 0 15218469Sjillescheck "1 || 0 / 0" 1 16218469Sjillescheck "0 && (ro = 2)" 0 17218469Sjillescheck "ro" 4 18218469Sjillescheck "1 || (ro = -1)" 1 19218469Sjillescheck "ro" 4 20218469Sjillescheck "0 && (rw += 1)" 0 21218469Sjillescheck "rw" 1 22218469Sjillescheck "1 || (rw += 1)" 1 23218469Sjillescheck "rw" 1 24218469Sjillescheck "0 ? 44 / 0 : 51" 51 25218469Sjillescheck "0 ? ro = 3 : 52" 52 26218469Sjillescheck "ro" 4 27218469Sjillescheck "0 ? rw += 1 : 52" 52 28218469Sjillescheck "rw" 1 29218469Sjillescheck "1 ? 68 : 30 / 0" 68 30218469Sjillescheck "2 ? 1 : (ro += 2)" 1 31218469Sjillescheck "ro" 4 32218469Sjillescheck "4 ? 1 : (rw += 1)" 1 33218469Sjillescheck "rw" 1 34218469Sjilles 35218469Sjillesexit $((failures != 0)) 36