X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fcommand.at;h=562c69b1304e22d306058eb4f1b3c028ded84711;hb=578bc59e7ec144bc8424e9a58807a791314cc0e8;hp=5636caff5fae56e44424cd036aa760ae17010c1c;hpb=102b36fbfea43934c8dbfe1daa8da6a705ad0f7c;p=pspp diff --git a/tests/language/command.at b/tests/language/command.at index 5636caff5f..562c69b130 100644 --- a/tests/language/command.at +++ b/tests/language/command.at @@ -1,3 +1,72 @@ +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([command parser]) + +AT_SETUP([command parser negative tests]) +AT_DATA([command.sps], [dnl +DATA X. +XYZZY. +CLOSE FILE XYZZY. +foo. +]) +AT_CHECK([pspp command.sps], [1], [dnl +command.sps:1.1-1.6: error: Unknown command `DATA X'. + 1 | DATA X. + | ^~~~~~ + +command.sps:2.1-2.5: error: Unknown command `XYZZY'. + 2 | XYZZY. + | ^~~~~ + +command.sps:3.1-3.16: error: Unknown command `CLOSE FILE XYZZY'. + 3 | CLOSE FILE XYZZY. + | ^~~~~~~~~~~~~~~~ + +command.sps:4.1-4.3: error: Unknown command `foo'. + 4 | foo. + | ^~~ +]) +AT_CLEANUP + +dnl Tests for a bug which crashed pspp when given certain invalid input. +AT_SETUP([command parser crash bug]) +AT_DATA([command.sps], [dnl +DATA rubbish. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv command.sps], [1], [dnl +"command.sps:1.1-1.12: error: Unknown command `DATA rubbish'. + 1 | DATA rubbish. + | ^~~~~~~~~~~~" + +"command.sps:2.1-2.7: error: EXECUTE: EXECUTE is allowed only after the active dataset has been defined. + 2 | EXECUTE. + | ^~~~~~~" +]) +AT_CLEANUP + +dnl Tests for a bug where FINISH or EXIT wasn't executed until the lexer +dnl read the first token of the next command. +dnl +dnl (If this recurs, the test will run forever.) +AT_SETUP([FINISH executes immediately]) +AT_CHECK([(echo "FINISH."; while echo ; do true; done) | pspp], [0], [ignore], [ignore]) +AT_CLEANUP + AT_BANNER([ERASE]) AT_SETUP([ERASE -- safer mode]) @@ -9,7 +78,9 @@ set safer on erase FILE='foobar'. ]) AT_CHECK([pspp -O format=csv erase.sps], [1], [dnl -erase.sps:3: error: ERASE: This command not allowed when the SAFER option is set. +"erase.sps:3.1-3.5: error: ERASE: This command not allowed when the SAFER option is set. + 3 | erase FILE='foobar'. + | ^~~~~" ]) AT_CHECK([cat foobar], [0], [contents ]) @@ -25,3 +96,51 @@ erase FILE='foobar'. AT_CHECK([pspp -O format=csv erase.sps]) AT_CHECK([test ! -e foobar]) AT_CLEANUP + +AT_BANNER([N OF CASES]) + +AT_SETUP([N OF CASES]) +AT_DATA([n-of-cases.sps], [dnl +INPUT PROGRAM. +LOOP #i = 1 TO 100. +COMPUTE x=#i. +END CASE. +END LOOP. +END FILE. +END INPUT PROGRAM. + +N OF CASES 15. + +LIST. +]) +AT_CHECK([pspp -O format=csv n-of-cases.sps], [0], [dnl +Table: Data List +x +1.00 +2.00 +3.00 +4.00 +5.00 +6.00 +7.00 +8.00 +9.00 +10.00 +11.00 +12.00 +13.00 +14.00 +15.00 +]) +AT_CLEANUP + +AT_BANNER([COMMENT]) + +dnl Tests for a bug wherein a comment just before end-of-file caused an +dnl infinite loop. +AT_SETUP([COMMENT at end of file]) +AT_DATA([comment.sps], [dnl +COMMENT this is a comment at end of file. +]) +AT_CHECK([pspp -O format=csv comment.sps]) +AT_CLEANUP