X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fdata-io%2Fprint.at;h=c9dd0908eab8ed42a5b2540e183fcc2fbac1e322;hb=60c545e6e958d868db3399a8989d37d8f9e0c131;hp=f1fae5de67503050b3e1100e7ad939982a062c0f;hpb=736af120ae00b122994e9e023a29c43ad722a46e;p=pspp diff --git a/tests/language/data-io/print.at b/tests/language/data-io/print.at index f1fae5de67..c9dd0908ea 100644 --- a/tests/language/data-io/print.at +++ b/tests/language/data-io/print.at @@ -1,3 +1,19 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([PRINT and WRITE]) dnl These tests check unusual aspects of the PRINT and WRITE @@ -41,50 +57,36 @@ AT_CHECK([pspp -O format=csv print.sps], [0], [dnl 12 - 1 -2 @&t@ - - 3 4 @&t@ 34 - 3 -4 @&t@ - - . 6 @&t@ .6 - . -6 @&t@ - - 7 . @&t@ 7. - 7 -. @&t@ - - 9 0 @&t@ 90 - 9 -0 @&t@ - ]) AT_CLEANUP @@ -172,7 +174,7 @@ PRINT F8.2 LIST. ]) AT_CHECK([pspp -O format=csv print.sps], [1], [dnl -print.sps:7: error: PRINT: Syntax error at `F8.2': expecting a valid subcommand. +print.sps:7.7-7.10: error: PRINT: Syntax error at `F8.2': expecting a valid subcommand. Table: Data List a,b @@ -223,3 +225,115 @@ AT_CHECK([cat write.out], [0], [dnl ]) AT_CLEANUP + +AT_SETUP([PRINT overwrites file]) +AT_DATA([output.txt], [abcdef +]) +AT_DATA([print.sps], [dnl +DATA LIST NOTABLE/x 1. +BEGIN DATA. +5 +END DATA. +PRINT OUTFILE='output.txt'/x. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat output.txt], [0], [ 5 @&t@ +]) +AT_CLEANUP + +AT_SETUP([PRINT overwrites file atomically]) +AT_DATA([output.txt], [abcdef +]) +AT_DATA([print.sps], +[[DATA LIST NOTABLE/x 1. +BEGIN DATA. +5 +END DATA. +PRINT OUTFILE='output.txt'/x. +HOST COMMAND=['kill -TERM $PPID']. +]]) +AT_CHECK([pspp -O format=csv print.sps], [143], [], [ignore]) +AT_CHECK([cat output.txt], [0], [abcdef +]) +AT_CHECK( + [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done]) +AT_CLEANUP + +AT_SETUP([PRINT to same file being read]) +AT_DATA([data.txt], [5 +]) +AT_DATA([print.sps], [dnl +DATA LIST FILE='data.txt' NOTABLE/x 1. +COMPUTE y = x + 1. +PRINT OUTFILE='data.txt'/y. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat data.txt], [0], [ 6.00 @&t@ +]) +AT_CHECK( + [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done]) +AT_CLEANUP + +AT_SETUP([PRINT to special file]) +AT_SKIP_IF([test ! -c /dev/null]) +AT_CHECK([ln -s /dev/null foo.out || exit 77]) +AT_SKIP_IF([test ! -c foo.out]) +AT_DATA([print.sps], [dnl +DATA LIST NOTABLE /x 1. +BEGIN DATA. +1 +2 +3 +4 +5 +END DATA. +PRINT OUTFILE='foo.out'/x. +PRINT OUTFILE='foo2.out'/x. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat foo2.out], [0], [dnl + 1 @&t@ + 2 @&t@ + 3 @&t@ + 4 @&t@ + 5 @&t@ +]) +ls -l foo.out foo2.out +AT_CHECK([test -c foo.out]) +AT_CLEANUP + +AT_SETUP([PRINT with special line ends]) +AT_DATA([print.sps], [dnl +FILE HANDLE lf /NAME='lf.txt' /ENDS=LF. +FILE HANDLE crlf /NAME='crlf.txt' /ENDS=CRLF. +DATA LIST NOTABLE /x 1. +BEGIN DATA. +1 +2 +3 +4 +5 +END DATA. +PRINT OUTFILE=lf/x. +PRINT OUTFILE=crlf/x. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat lf.txt], [0], [dnl + 1 @&t@ + 2 @&t@ + 3 @&t@ + 4 @&t@ + 5 @&t@ +]) +AT_CHECK([tr '\r' R < crlf.txt], [0], [dnl + 1 R + 2 R + 3 R + 4 R + 5 R +]) +AT_CLEANUP