tests: Convert test for VALUELABEL expression function to Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 12 Oct 2010 05:30:27 +0000 (22:30 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 12 Oct 2010 05:30:27 +0000 (22:30 -0700)
tests/automake.mk
tests/expressions/valuelabel.sh [deleted file]
tests/language/expressions/evaluate.at

index 2c09e4b33856de0fbe59ecd2f4f2f0543c3062b2..63bb79b8ba8d90e205de0f9efa355775191ad739 100644 (file)
@@ -27,7 +27,6 @@ dist_TESTS = \
        tests/formats/wkday-in.sh \
        tests/formats/wkday-out.sh \
        tests/formats/360.sh \
-       tests/expressions/valuelabel.sh \
        tests/expressions/variables.sh \
        tests/expressions/vectors.sh
 
diff --git a/tests/expressions/valuelabel.sh b/tests/expressions/valuelabel.sh
deleted file mode 100755 (executable)
index d4fa74f..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-# This program tests use of the VALUELABEL function in expressions.
-
-TEMPDIR=/tmp/pspp-tst-$$
-
-# ensure that top_srcdir and top_builddir  are absolute
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-top_srcdir=`cd $top_srcdir; pwd`
-top_builddir=`cd $top_builddir; pwd`
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-LANG=C
-export LANG
-
-cleanup()
-{
-     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR" 
-       return ; 
-     fi
-     cd /
-     rm -rf $TEMPDIR
-}
-
-
-fail()
-{
-    echo $activity
-    echo FAILED
-    cleanup;
-    exit 1;
-}
-
-
-no_result()
-{
-    echo $activity
-    echo NO RESULT;
-    cleanup;
-    exit 2;
-}
-
-pass()
-{
-    cleanup;
-    exit 0;
-}
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create program"
-cat > $TEMPDIR/valuelabel.stat <<EOF
-DATA LIST notable /n 1 s 2(a).
-VALUE LABELS /n 0 'Very dissatisfied'
-                1 'Dissatisfied'
-               1.5 'Slightly Peeved'
-                2 'Neutral'
-                3 'Satisfied'
-                4 'Very satisfied'.
-VALUE LABELS /s 'a' 'Wouldn''t buy again'
-                'b' 'Unhappy'
-                'c' 'Bored'
-                'd' 'Satiated'
-                'e' 'Elated'.
-STRING nlabel slabel(a10).
-COMPUTE nlabel = VALUELABEL(n).
-COMPUTE slabel = VALUELABEL(s).
-LIST.
-BEGIN DATA.
-
-0a
-1b
-2c
-3d
-4e
-5f
-6g
-END DATA.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/valuelabel.stat
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="compare results"
-diff -c $TEMPDIR/pspp.csv - <<EOF
-Table: Data List
-n,s,nlabel,slabel
-.,,,
-0,a,Very dissa,Wouldn't b
-1,b,Dissatisfi,Unhappy   
-2,c,Neutral   ,Bored     
-3,d,Satisfied ,Satiated  
-4,e,Very satis,Elated    
-5,f,,
-6,g,,
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-
-pass;
index f712b4c047eaa2d0a85c3fd3c9821680b5b77894..d06270af0f09a0816c9a4d9f1a7578e9fce871cf 100644 (file)
@@ -1942,3 +1942,47 @@ R1
 1.50
 ])
 AT_CLEANUP
+
+AT_SETUP([VALUELABEL function])
+AT_DATA([valuelabel.sps], [dnl
+DATA LIST notable /n 1 s 2(a).
+VALUE LABELS /n 0 'Very dissatisfied'
+                1 'Dissatisfied'
+               1.5 'Slightly Peeved'
+                2 'Neutral'
+                3 'Satisfied'
+                4 'Very satisfied'.
+VALUE LABELS /s 'a' 'Wouldn''t buy again'
+                'b' 'Unhappy'
+                'c' 'Bored'
+                'd' 'Satiated'
+                'e' 'Elated'.
+STRING nlabel slabel(a10).
+COMPUTE nlabel = VALUELABEL(n).
+COMPUTE slabel = VALUELABEL(s).
+LIST.
+BEGIN DATA.
+
+0a
+1b
+2c
+3d
+4e
+5f
+6g
+END DATA.
+])
+AT_CHECK([pspp -o pspp.csv valuelabel.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+n,s,nlabel,slabel
+.,,,
+0,a,Very dissa,Wouldn't b
+1,b,Dissatisfi,Unhappy   @&t@
+2,c,Neutral   ,Bored     @&t@
+3,d,Satisfied ,Satiated  @&t@
+4,e,Very satis,Elated    @&t@
+5,f,,
+6,g,,
+])
+AT_CLEANUP