Add copyright and licence notices to files which lack them.
[pspp] / tests / language / utilities / insert.at
index e119f1033bc4a5794dc54c6f965a11d91ab59a86..0b120ebb3fe05be7d9e8b8a22e4aa999cdc42312 100644 (file)
@@ -1,15 +1,30 @@
-AT_BANNER([INSERT])
+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 <http://www.gnu.org/licenses/>.
+dnl AT_BANNER([INSERT])
 
 dnl Create a file "batch.sps" that is valid syntax only in batch mode.
 m4_define([CREATE_BATCH_SPS], 
   [AT_DATA([batch.sps], [dnl
-input program.
-+  loop #i = 1 to 5.
-+    compute z = #i
-+    end case.
-+  end loop
-end file.
-end input program.
+input program
+loop #i = 1 to 5
++  compute z = #i
++  end case
+end loop
+end file
+end input program
 ])])
 
 AT_SETUP([INSERT SYNTAX=INTERACTIVE])
@@ -17,15 +32,14 @@ CREATE_BATCH_SPS
 AT_DATA([insert.sps], [dnl
 INSERT 
   FILE='batch.sps'
-  SYNTAX=INTERACTIVE.
+  SYNTAX=interactive.
 LIST.
 ])
 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
-batch.sps:2: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
-batch.sps:3: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
-batch.sps:5: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
-batch.sps:7: error: Input program did not create any variables.
-insert.sps:4: error: LIST: LIST is allowed only after the active file has been defined.
+batch.sps:2.1-2.4: error: INPUT PROGRAM: Syntax error at `loop': expecting end of command.
+batch.sps:3: error: COMPUTE: COMPUTE is allowed only after the active dataset has been defined or inside INPUT PROGRAM.
+batch.sps:4: error: END CASE: END CASE is allowed only inside INPUT PROGRAM.
+insert.sps:4: error: LIST: LIST is allowed only after the active dataset has been defined.
 ])
 AT_CLEANUP
 
@@ -66,7 +80,7 @@ END DATA.
 ])
 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
 Dir1/foo.sps:1: error: INSERT: Can't find `bar.sps' in include file search path.
-insert.sps:2: error: LIST: LIST is allowed only after the active file has been defined.
+insert.sps:2: error: LIST: LIST is allowed only after the active dataset has been defined.
 ])
 AT_CLEANUP
 
@@ -111,24 +125,22 @@ END DATA.
 * The following line is erroneous
 
 DISPLAY AKSDJ.
+LIST.
 ])])
 
 AT_SETUP([INSERT ERROR=STOP])
 CREATE_ERROR_SPS
 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=STOP.
-LIST.
 ])
 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
 warning: Error encountered while ERROR=STOP is effective.
-error.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
 ])
 AT_CLEANUP
 
 AT_SETUP([INSERT ERROR=CONTINUE])
 CREATE_ERROR_SPS
 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=CONTINUE.
-LIST.
 ])
 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
@@ -156,8 +168,44 @@ INSERT
 LIST.
 ])
 AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
-insert.sps:3: error: INSERT: Can't find `nonexistent' in include file search path.
+insert.sps:2: error: INSERT: Can't find `nonexistent' in include file search path.
+
+insert.sps:6: error: LIST: LIST is allowed only after the active dataset has been defined.
+])
+AT_CLEANUP
 
-insert.sps:6: error: LIST: LIST is allowed only after the active file has been defined.
+
+dnl A test to check the INCLUDE command complete with the 
+dnl syntax and function of the ENCODING subcommand.
+AT_SETUP([INCLUDE full check])
+AT_DATA([two-utf8.sps], [dnl
+echo 'Äpfelfölfaß'.
+])
+
+AT_DATA([include.sps], [dnl
+echo 'ONE'.
+
+include FILE='two-latin1.sps' ENCODING='ISO_8859-1'.
 ])
+
+AT_CHECK([iconv -f UTF-8 -t iso-8859-1 two-utf8.sps > two-latin1.sps], [0], [])
+
+AT_CHECK([pspp -O format=csv include.sps], [0], [dnl
+ONE
+
+Äpfelfölfaß
+])
+AT_CLEANUP
+
+
+
+
+dnl Test for a bug where insert crashed on an unterminated string input
+AT_SETUP([INSERT unterminated string])
+
+AT_DATA([insert.sps], [INSERT FILE=7bar.sps' CD=NO.
+])
+
+AT_CHECK([pspp -O format=csv insert.sps], [1], [ignore])
+
 AT_CLEANUP