SYSFILE INFO: Get rid of nested tables.
[pspp] / tests / language / dictionary / sort-variables.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
17 AT_BANNER([SORT VARIABLES])
18
19 AT_SETUP([SORT VARIABLES])
20 # This reverses the order of its input lines.
21 # From the GNU sed manual.
22 tac () {
23     sed -n '1! G
24 $ p
25 h'
26 }
27
28 test_sort () {
29     cat > sort-variables.sps <<EOF
30 DATA LIST FREE/$1.
31 $2
32 SORT VARIABLES $3.
33 DISPLAY NAMES.
34 SORT VARIABLES $3(D).
35 DISPLAY NAMES.
36 EOF
37     AT_CHECK_UNQUOTED([pspp -O format=csv sort-variables.sps], [0],
38 [Table: Variables
39 Name
40 `for var in $4; do echo $var; done`
41
42 Table: Variables
43 Name
44 `for var in $4; do echo $var; done | tac`
45 ])
46 }
47
48 test_sort 'x100 c b x99 a y400 y5' '' NAME 'a b c x99 x100 y5 y400'
49 test_sort 'c(a10) a(a5) b' '' TYPE 'b a c'
50 test_sort 'a (datetime) b (f) c (a5) d (a2) e (a1)' '' FORMAT 'e d c b a'
51 test_sort 'a b c' \
52     'VARIABLE LABEL a "hi there".' \
53     LABEL 'b c a'
54 test_sort 'a b c' \
55     'VALUE LABELS a 123 "xyzzy".' \
56     VALUES 'b c a'
57 test_sort 'a b c' \
58     'MISSING VALUES a (123).' \
59     MISSING 'b c a'
60 test_sort 'a b c' \
61     'VARIABLE LEVEL a (SCALE) b (ORDINAL) c (NOMINAL).' \
62     MEASURE 'c b a'
63 test_sort 'b n i s t p' \
64     'VARIABLE ROLE /INPUT i /TARGET t /BOTH b /NONE n /PARTITION p /SPLIT s.' \
65     ROLE 'i t b n p s'
66 test_sort 'c10 c5 c15 c9' \
67     'VARIABLE WIDTH c10(10) c5(5) c15(15) c9(9).' \
68     COLUMNS 'c5 c9 c10 c15'
69 test_sort 'c l r' \
70     'VARIABLE ALIGNMENT c (CENTER) l (LEFT) r (RIGHT).' \
71     ALIGNMENT 'l r c'
72 test_sort 'az ax ay ab' \
73     'VARIABLE ATTRIBUTE VARIABLES=az ATTRIBUTE=key("z").
74      VARIABLE ATTRIBUTE VARIABLES=ax ATTRIBUTE=key("x").
75      VARIABLE ATTRIBUTE VARIABLES=ay ATTRIBUTE=key("y").
76      VARIABLE ATTRIBUTE VARIABLES=ab ATTRIBUTE=key("b").' \
77     'ATTRIBUTE key' 'ab ax ay az'
78 AT_CLEANUP