summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2017-02-19 18:23:36 -0600
committerNicolas Williams <nico@cryptonector.com>2017-02-25 19:13:28 -0600
commit8619c6e060686c734f1743dcb687534839cbfa80 (patch)
tree1b093d2c3c8286143d7fd458e038659a031bad83 /tests
parent2e1f2db8b5dcaa4119a47b1a9ca83d9e048ce304 (diff)
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.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/shtest22
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/shtest b/tests/shtest
index 2614e900..9a17aea4 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -29,50 +29,46 @@ $VALGRIND $Q $JQ -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
## move all of these into tests/all.test
# String constant folding (addition only)
-n=`$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
+nref=`$VALGRIND $Q $JQ -n --debug-dump-disasm '"foo"' | wc -l`
# Numeric constant folding (not all ops yet)
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi
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"
exit 1
fi