]> granicus.if.org Git - jq/commitdiff
Make test/shtest test of constant folding robust
authorNicolas Williams <nico@cryptonector.com>
Mon, 20 Feb 2017 00:23:36 +0000 (18:23 -0600)
committerNicolas Williams <nico@cryptonector.com>
Sun, 26 Feb 2017 01:13:28 +0000 (19:13 -0600)
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.

tests/shtest

index 2614e90062d1a71bb07e6427ad78265bf573cffc..9a17aea4832f44491793f1e3070dc2e39038a8d5 100755 (executable)
@@ -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