+
+dnl This checks for a bug in the portable file writer that caused an infinite
+dnl loop in some cases, and other problems in other cases, when a variable
+dnl had value labels.
+AT_SETUP([write portable file with value labels])
+AT_DATA([export.sps], [dnl
+DATA LIST NOTABLE/var1 TO var5 1-5.
+VALUE LABELS
+ /var1 1 'one'
+ /var2 2 'two'
+ /var3 3 'three'
+ /var4 4 'four'
+ /var5 5 'five'.
+BEGIN DATA.
+12345
+END DATA.
+EXPORT OUTFILE='data.por'.
+])
+AT_CHECK([pspp -O format=csv export.sps])
+AT_DATA([import.sps], [dnl
+IMPORT FILE='data.por'.
+DISPLAY DICTIONARY.
+LIST.
+])
+AT_CHECK([pspp -O format=csv import.sps], [0], [dnl
+Table: Variables
+Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
+VAR1,1,,Scale,Input,8,Right,F1.0,F1.0,
+VAR2,2,,Scale,Input,8,Right,F1.0,F1.0,
+VAR3,3,,Scale,Input,8,Right,F1.0,F1.0,
+VAR4,4,,Scale,Input,8,Right,F1.0,F1.0,
+VAR5,5,,Scale,Input,8,Right,F1.0,F1.0,
+
+Table: Value Labels
+Variable Value,,Label
+VAR1,1,one
+VAR2,2,two
+VAR3,3,three
+VAR4,4,four
+VAR5,5,five
+
+Table: Data List
+VAR1,VAR2,VAR3,VAR4,VAR5
+1,2,3,4,5
+])
+AT_DATA([sys-file-info.sps], [SYSFILE INFO FILE='data.por'
+])
+AT_CHECK([pspp -O format=csv sys-file-info.sps | sed '/Encoding/d
+/Integer Format/d
+/Real Format/d
+/Created/d
+/Product/d
+'], [0], [dnl
+Table: File Information
+File,data.por
+Label,
+Variables,5
+Cases,Unknown
+Type,SPSS Portable File
+Weight,Not weighted
+Compression,None
+
+Table: Variables
+Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
+VAR1,1,,Scale,Input,8,Right,F1.0,F1.0,
+VAR2,2,,Scale,Input,8,Right,F1.0,F1.0,
+VAR3,3,,Scale,Input,8,Right,F1.0,F1.0,
+VAR4,4,,Scale,Input,8,Right,F1.0,F1.0,
+VAR5,5,,Scale,Input,8,Right,F1.0,F1.0,
+
+Table: Value Labels
+Variable Value,,Label
+VAR1,1,one
+VAR2,2,two
+VAR3,3,three
+VAR4,4,four
+VAR5,5,five
+])
+AT_CLEANUP