Add copyright and licence notices to files which lack them.
[pspp] / tests / data / format-guesser.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 AT_BANNER([format guesser])
17
18 AT_SETUP([format guesser])
19 AT_DATA([format-guesser.txt], [dnl
20 # No data.
21 => F8.2
22 "" => F8.2
23 "." => F8.2
24
25 # Numeric formats.
26 "1.2" => F3.1
27 "$1.2" => DOLLAR4.1
28 "1.2%" => PCT4.1
29 "$1.2%" => A5
30 "1e5" => E3.0
31 "1e+5" => E4.0
32 "1+5" => E3.0
33 "1-5" => E3.0
34 "1.2e5" => E5.1
35 "1.3e+5" => E6.1
36 "1.4+5" => E5.1
37 "1e" => A2
38 "1e+" => A3
39 "1+" => A2
40 "1-" => A2
41 "1.5-5" => E5.1
42 "1,123" => COMMA5.0         # Is , is grouping or decimal? Assume grouping.
43 "1.123" => F5.3             # Ditto.
44 "1,12" => F4.2              # Not a group of 3, so last delim must be decimal.
45 "1.12" => F4.2              # Ditto.
46 "1,1234" => F6.4            # Not a group of 3, so last delim must be decimal.
47 "1.1234" => F6.4            # Ditto.
48 "$1.234" => DOLLAR6.3       # Dollar sign means decimal has to be '.'.
49 "$1,234" => DOLLAR6.0       # Ditto.
50 "1.234%" => PCT6.3          # Percent sign means decimal has to be '.'.
51 "1,234%" => PCT6.0          # Ditto.
52 "1,123.456" => COMMA9.3     # Both '.' and ',', so last delim must be decimal.
53 "1.123,456" => DOT9.3       # Ditto.
54 "1,123,456.45" => COMMA12.2 # Ditto.
55 "1.123.456,45" => DOT12.2   # Ditto.
56 "1,123,456" => COMMA9.0     # Ditto.
57 "1.123.456" => DOT9.0       # Ditto.
58
59 # Date and time formats.
60 "01-OCT-1978" => DATE11
61 "01-x-1978" => EDATE9           # Roman numeral for month.
62 "01-13-99" => ADATE8
63 "1-13-99" => ADATE7 (ADATE8)
64 "13-01-99" => EDATE8
65 "13-1-99" => EDATE7 (EDATE8)
66 "32-1-1" => SDATE6 (SDATE8)
67 "1q01" => QYR4
68 "1Q01" => QYR4
69 "1 q 01" => QYR6
70 "1 Q 01" => QYR6
71 "1q2001" => QYR6
72 "1Q2001" => QYR6
73 "1 q 2001" => QYR8
74 "1 Q 2001" => QYR8
75 "oct 05" => MOYR6
76 "oct 2005" => MOYR8
77 "1-1-01 1:2" => A10             # Minute needs at least two digits.
78 "1-1-01 1:02" => DATETIME11.0 (DATETIME17.0)
79 "1-1-01 1:02:3" => A13          # Second needs at least two digits.
80 "1-1-01 1:02:03" => DATETIME20.0
81 "1-1-01 1:02:03.1" => DATETIME20.1 (DATETIME22.1)
82 "1-1-01 +1:02:03.1" => DATETIME20.1 (DATETIME22.1)
83 "1-1-01 -1:02:03.1" => DATETIME20.1 (DATETIME22.1)
84 "1:30" => TIME4.0 (TIME5.0)
85 "1:30:05" => TIME8.0
86 "-1:30" => TIME5.0
87 "+1:30" => TIME5.0
88 "-1:30:15" => TIME8.0
89 "+1:30:15" => TIME8.0
90 "-1:30:15.5" => TIME10.1
91 "+1:30:15.75" => TIME11.2
92 "1 1:30" => DTIME6.0 (DTIME8.0)
93 "+1 1:30" => DTIME7.0 (DTIME8.0)
94 "-1 1:30" => DTIME7.0 (DTIME8.0)
95 "-1-13-99" => A8
96 "+1-13-99" => A8
97 "1+13+99" => A7
98 "1:00:01.03" => TIME10.2 (TIME11.2)
99 "12 1:00:01.3" => DTIME12.1 (DTIME13.1)
100 "jan" => MONTH3
101 "Feb" => MONTH3
102 "MAR" => MONTH3
103 "i" => A1                       # Not detected as MONTH format.
104 "v" => A1
105 "ix" => A2
106 "x" => A1
107 "january" => MONTH7
108 "janaury" => MONTH7             # Only first three letters are significant.
109 "february" => MONTH8
110 "febraury" => MONTH8
111 "march" => MONTH5
112 "marhc" => MONTH5
113 "april" => MONTH5
114 "may" => MONTH3
115 "june" => MONTH4
116 "july" => MONTH4
117 "august" => MONTH6
118 "september" => MONTH9
119 "october" => MONTH7
120 "november" => MONTH8
121 "decmeber" => MONTH8
122 "december" => MONTH8
123 "monady" => WKDAY6
124 "tuseday" => WKDAY7
125 "wedensday" => WKDAY9
126 "thurdsay" => WKDAY8
127 "fridya" => WKDAY6
128 "saturady" => WKDAY8
129 "sudnay" => WKDAY6
130
131 # Ambiguous; bias in favor of more sensible DD/MM/YY format:
132 "1/1/1978" => EDATE8
133 "01/01/01" => EDATE8
134
135 # Several ambiguous dates can be clarified by one unambiguous example:
136 "1/1/1978" "1/2/1978" "1/3/1978" "1/13/1978" => ADATE9 # MM/DD/YY
137 "01/01/01" "02/01/01" "03/01/01" "13/01/01" => EDATE8  # DD/MM/YY
138 "01/01/01" "02/01/01" "03/01/01" "2013/01/01" => SDATE10 # YY/MM/DD
139 ])
140 AT_CHECK([[(echo "SET DECIMAL=DOT."
141            sed -e 's/#.*//
142 s/[     ]*$//
143 /^$/d
144 s,^\(.*\)=> \(.*\)$,DEBUG FORMAT GUESSER \1.,') \
145            < format-guesser.txt > format-guesser.sps]])
146 AT_CHECK([pspp --testing-mode -O format=csv format-guesser.sps],
147   [0], [], [stderr])
148 AT_CHECK([[sed -e 's/#.*//
149 s/[     ]*$//
150 /^$/d' < format-guesser.txt > expout]])
151 AT_CHECK([cat stderr], [0], [expout])
152 AT_CLEANUP