+
+AT_CHECK([pspp -O format=csv ar.sps], [0],
+ [Table: Recoding s into new (tracking my stuff).
+Old Value,New Value,Value Label
+oojars,1,oojars
+oojimiflips,2,oojimiflips
+thingummies,3,Funny sticky things
+widgets,4,widgets
+
+Table: Data List
+s,x,new
+widgets,1,4
+thingummies,2,3
+oojars,3,1
+widgets,4,4
+oojars,5,1
+thingummies,6,3
+oojimiflips,7,2
+
+Table: Variables
+Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format
+new,3,tracking my stuff,Nominal,Input,8,Right,F1.0,F1.0
+
+Table: Value Labels
+Variable Value,,Label
+tracking my stuff,1,oojars
+,2,oojimiflips
+,3,Funny sticky things
+,4,widgets
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([AUTORECODE group subcommand])
+AT_DATA([ar-group.sps],
+[data list notable list /x y (f8.0).
+begin data.
+11 10
+12 12
+13 15
+14 11
+15 12
+16 18
+end data.
+
+missing values y (12).
+
+autorecode
+ x y into a b
+ /group
+ /print.
+
+list.
+display variables /variables=a b.
+])
+
+AT_CHECK([pspp -O format=csv ar-group.sps], [0],
+[Table: Recoding grouped variables.
+Old Value,New Value,Value Label
+10,1,10
+11,2,11
+13,3,13
+14,4,14
+15,5,15
+16,6,16
+18,7,18
+12,8,12
+
+Table: Data List
+x,y,a,b
+11,10,2,1
+12,12,8,8
+13,15,3,5
+14,11,4,2
+15,12,5,8
+16,18,6,7
+
+Table: Variables
+Name,Position,Print Format,Write Format,Missing Values
+a,3,F1.0,F1.0,8
+b,4,F1.0,F1.0,8
+])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([AUTORECODE group - string variables])
+AT_DATA([strings.sps],
+[data list notable list /x (a8) y (a16).
+begin data.
+fred bert
+charlie " "
+delta echo
+" " windows
+" " nothing
+end data.
+
+
+autorecode x y into a b
+ /group
+ /print.
+
+delete variables x y.
+
+list.
+
+])
+
+AT_CHECK([pspp -O format=csv strings.sps], [0],
+[Table: Recoding grouped variables.
+Old Value,New Value,Value Label
+,1,
+bert,2,bert
+charlie,3,charlie
+delta,4,delta
+echo,5,echo
+fred,6,fred
+nothing,7,nothing
+windows,8,windows
+
+Table: Data List
+a,b
+6,2
+3,1
+4,5
+1,8
+1,7
+])
+
+AT_CLEANUP
+
+
+dnl Tests for a crash which happened when the /GROUP subcommand
+dnl appeared with string variables of different widths.
+AT_SETUP([AUTORECODE group vs. strings])
+AT_DATA([ar-strings.sps],
+ [data list notable list /a (a12) b (a6).
+begin data.
+one nine
+two ten
+three eleven
+four nought
+end data.
+
+autorecode a b into x y
+ /group
+ /print.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv ar-strings.sps], [0], [dnl
+Table: Recoding grouped variables.
+Old Value,New Value,Value Label
+eleven,1,eleven
+four,2,four
+nine,3,nine
+nought,4,nought
+one,5,one
+ten,6,ten
+three,7,three
+two,8,two
+
+Table: Data List
+a,b,x,y
+one,nine,5,3
+two,ten,8,6
+three,eleven,7,1
+four,nought,2,4
+])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([AUTORECODE /blank])
+
+AT_DATA([auto-blank.sps], [dnl
+data list notable list /x (a8) y (f8.0) z (a16).
+begin data.
+one 2 fred
+two 4 ""
+"" 4 fred
+"" 2 charliebrown
+three 2 charliebrown
+end data.
+
+autorecode variables x y z into a b c /blank=missing /print.
+
+list a b c y.
+])
+
+AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl
+Table: Recoding x into a.
+Old Value,New Value,Value Label
+one,1,one
+three,2,three
+two,3,two
+
+Table: Recoding y into b.
+Old Value,New Value,Value Label
+2,1,2
+4,2,4
+
+Table: Recoding z into c.
+Old Value,New Value,Value Label
+charliebrown,1,charliebrown
+fred,2,fred
+
+Table: Data List
+a,b,c,y
+1,1,2,2
+3,2,.,4
+.,2,2,4
+.,1,1,2
+2,1,1,2
+])
+
+AT_CLEANUP
+
+dnl AUTORECODE had a use-after-free error when TEMPORARY was in use.
+dnl Bug #32757.
+AT_SETUP([AUTORECODE with TEMPORARY])
+AT_DATA([autorecode.sps],
+ [data list /X 1-5(a) Y 7.
+begin data.
+lasdj 1
+asdfk 0
+asdfj 2
+asdfj 1
+asdfk 2
+asdfj 9
+lajks 9
+asdfk 0
+asdfk 1
+end data.
+
+temporary.
+select if y > 1.
+autorecode x y into A B/descend/print.
+list.
+])
+AT_CHECK([pspp -O format=csv autorecode.sps], [0], [dnl
+Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+X,1,1-5,A5
+Y,1,7-7,F1.0
+
+Table: Recoding X into A.
+Old Value,New Value,Value Label
+lajks,1,lajks
+asdfk,2,asdfk
+asdfj,3,asdfj
+
+Table: Recoding Y into B.
+Old Value,New Value,Value Label
+9,1,9
+2,2,2
+
+Table: Data List
+X,Y,A,B
+lasdj,1,.,.
+asdfk,0,2,.
+asdfj,2,3,2
+asdfj,1,3,.
+asdfk,2,2,2
+asdfj,9,3,1
+lajks,9,1,1
+asdfk,0,2,.
+asdfk,1,2,.
+])
+AT_CLEANUP
+
+
+dnl For compatibility, make sure that /INTO (with leading slash) is accepted
+dnl (bug #48762)
+AT_SETUP([AUTORECODE with /INTO])
+AT_DATA([autorecode.sps],
+ [data list list notable /x (f8.0).
+begin data.
+1
+8
+-901
+4
+1
+99
+8
+end data.
+
+autorecode x /into y /print.
+
+list.
+])
+AT_CHECK([pspp -O format=csv autorecode.sps], [0],
+[Table: Recoding x into y.
+Old Value,New Value,Value Label
+-901,1,-901
+1,2,1
+4,3,4
+8,4,8
+99,5,99
+
+Table: Data List
+x,y
+1,2
+8,4
+-901,1
+4,3
+1,2
+99,5
+8,4
+])
+AT_CLEANUP
+
+
+AT_SETUP([AUTORECODE with /BLANK without specifier])
+
+AT_DATA([autorecode.sps], [data list notable list /x (a18).
+begin data
+one
+two
+three
+end data.
+
+* /BLANK should be either =MISSING or =VALID
+autorecode x /into y
+ /blank
+
+execute.
+])
+
+AT_CHECK([pspp -O format=csv autorecode.sps], [1], [ignore])
+