]>
Commit | Line | Data |
---|---|---|
deb63bfb | 1 | # $FreeBSD: head/bin/sh/tests/expansion/arith14.0 270029 2014-08-15 22:36:41Z jilles $ |
71aad674 A |
2 | # Check that <</>> use the low bits of the shift count. |
3 | ||
4 | if [ $((1<<16<<16)) = 0 ]; then | |
5 | width=32 | |
6 | elif [ $((1<<32<<32)) = 0 ]; then | |
7 | width=64 | |
8 | elif [ $((1<<64<<64)) = 0 ]; then | |
9 | width=128 | |
10 | elif [ $((1<<64>>64)) = 1 ]; then | |
11 | # Integers are wider than 128 bits; assume arbitrary precision. | |
12 | # Nothing to test here. | |
13 | exit 0 | |
14 | else | |
15 | echo "Cannot determine integer width" | |
16 | exit 2 | |
17 | fi | |
18 | ||
19 | twowidth=$((width * 2)) | |
20 | j=43 k=$((1 << (width - 2))) r=0 | |
21 | ||
22 | i=0 | |
23 | while [ $i -lt $twowidth ]; do | |
24 | if [ "$((j << i))" != "$((j << (i + width)))" ]; then | |
25 | echo "Problem with $j << $i" | |
26 | r=2 | |
27 | fi | |
28 | i=$((i + 1)) | |
29 | done | |
30 | ||
31 | i=0 | |
32 | while [ $i -lt $twowidth ]; do | |
33 | if [ "$((k >> i))" != "$((k >> (i + width)))" ]; then | |
34 | echo "Problem with $k >> $i" | |
35 | r=2 | |
36 | fi | |
37 | i=$((i + 1)) | |
38 | done | |
39 | ||
40 | exit $r |