From 8619c6e060686c734f1743dcb687534839cbfa80 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sun, 19 Feb 2017 18:23:36 -0600 Subject: [PATCH] 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. --- tests/shtest | 22 +++++++++------------- 1 file 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