From 308a14f85158f1545000499a64bc170d688a0db9 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 10 Jan 2019 18:48:02 -0500 Subject: Import /usr/src/bin/sh from FreeBSD 12.0-RELEASE --- bin/cash/tests/expansion/arith14.0 | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bin/cash/tests/expansion/arith14.0 (limited to 'bin/cash/tests/expansion/arith14.0') diff --git a/bin/cash/tests/expansion/arith14.0 b/bin/cash/tests/expansion/arith14.0 new file mode 100644 index 00000000..5fa2dece --- /dev/null +++ b/bin/cash/tests/expansion/arith14.0 @@ -0,0 +1,40 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/expansion/arith14.0 270029 2014-08-15 22:36:41Z jilles $ +# Check that <> use the low bits of the shift count. + +if [ $((1<<16<<16)) = 0 ]; then + width=32 +elif [ $((1<<32<<32)) = 0 ]; then + width=64 +elif [ $((1<<64<<64)) = 0 ]; then + width=128 +elif [ $((1<<64>>64)) = 1 ]; then + # Integers are wider than 128 bits; assume arbitrary precision. + # Nothing to test here. + exit 0 +else + echo "Cannot determine integer width" + exit 2 +fi + +twowidth=$((width * 2)) +j=43 k=$((1 << (width - 2))) r=0 + +i=0 +while [ $i -lt $twowidth ]; do + if [ "$((j << i))" != "$((j << (i + width)))" ]; then + echo "Problem with $j << $i" + r=2 + fi + i=$((i + 1)) +done + +i=0 +while [ $i -lt $twowidth ]; do + if [ "$((k >> i))" != "$((k >> (i + width)))" ]; then + echo "Problem with $k >> $i" + r=2 + fi + i=$((i + 1)) +done + +exit $r -- cgit 1.4.1