Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / data-io / update.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl m4_define([CHECK_UPDATE],
17   [AT_SETUP([UPDATE $1 with $2])
18    AT_DATA([a.data], [dnl
19 1aB
20 8aM
21 3aE
22 5aG
23 0aA
24 5aH
25 6aI
26 7aJ
27 2aD
28 7aK
29 1aC
30 7aL
31 4aF
32 ])
33    AT_DATA([b.data], [dnl
34 1bN
35 3 O
36 4bP
37 6bQ
38 7bR
39 9bS
40 ])
41    m4_if([$1], [sav],
42      [AT_DATA([save-a.sps], [dnl
43 DATA LIST NOTABLE FILE='a.data' /a b c 1-3 (A).
44 SAVE OUTFILE='a.sav'.
45 ])
46       AT_CHECK([pspp -O format=csv save-a.sps])])
47    m4_if([$2], [sav],
48      [AT_DATA([save-b.sps], [dnl
49 DATA LIST NOTABLE FILE='b.data' /a b c 1-3 (A).
50 SAVE OUTFILE='b.sav'.
51 ])
52       AT_CHECK([pspp -O format=csv save-b.sps])])
53    AT_DATA([update.sps], [dnl
54 m4_if([$1], [sav], [], [DATA LIST NOTABLE FILE='a.data' /a b c 1-3 (A).])
55 m4_if([$2], [sav], [], [DATA LIST NOTABLE FILE='b.data' /a b c 1-3 (A).])
56 UPDATE
57     m4_if([$1], [sav], [FILE='a.sav'], [FILE=*]) /IN=InA /SORT
58     m4_if([$2], [sav], [FILE='b.sav'], [FILE=*]) /IN=InB /RENAME c=d
59     BY a.
60 LIST.
61 ])
62    cat update.sps
63    AT_CHECK([pspp -O format=csv update.sps], [0], [dnl
64 update.sps:6: warning: UPDATE: Encountered 3 sets of duplicate cases in the master file.
65
66 Table: Data List
67 a,b,c,d,InA,InB
68 0,a,A,,1,0
69 1,b,B,N,1,1
70 1,a,C,,1,0
71 2,a,D,,1,0
72 3,a,E,O,1,1
73 4,b,F,P,1,1
74 5,a,G,,1,0
75 5,a,H,,1,0
76 6,b,I,Q,1,1
77 7,b,J,R,1,1
78 7,a,K,,1,0
79 7,a,L,,1,0
80 8,a,M,,1,0
81 9,b,,S,0,1
82 ])
83 AT_CLEANUP
84 ])
85
86 AT_BANNER([UPDATE])
87
88 CHECK_UPDATE([sav], [sav])
89 CHECK_UPDATE([sav], [inline])
90 CHECK_UPDATE([inline], [sav])