Make test/shtest test of constant folding robust
Rather than testing that a constant expression produces so many instructions, test that a variety of of such expressions produce the same number of instructions. This will make future changes in the compiler less likely to break this test.
This commit is contained in:
1 parent
2e1f2db8b5
commit
8619c6e060
1 file changed
+9
-13
+9
-13
@@ -29,50 +29,46 @@ $VALGRIND $Q $JQ -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
|
|||||||
## move all of these into tests/all.test
|
## move all of these into tests/all.test
|
||||||
|
|
||||||
# String constant folding (addition only)
|
# String constant folding (addition only)
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '"foo"' | wc -l`
|
nref=`$VALGRIND $Q $JQ -n --debug-dump-disasm '"foo"' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
|
||||||
echo "Constant expression folding for strings didn't work"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Numeric constant folding (not all ops yet)
|
# Numeric constant folding (not all ops yet)
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1+1' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1+1' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1-1' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1-1' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '2*3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '2*3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9/3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9/3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9==3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9==3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9!=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9!=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9<=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9<=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9>=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9>=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne $nref ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user