tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / self-check-unindent.tap
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Sanity check for the automake testsuite.
18 # Check the 'unindent' subroutine.
19
20 . test-init.sh
21
22 plan_ 22
23
24 #------------------------------------------------------------------
25
26 will_test () { tst=$*; }
27
28 do_check ()
29 {
30   command_ok_ "$tst [simple, exit status]" \
31               eval 'unindent input > got'
32   command_ok_ "$tst [simple, output]" \
33               diff exp got
34   command_ok_ "$tst [parallel, exit status]" \
35               eval 'unindent input | unindent > got'
36   command_ok_ "$tst [parallel, output]" \
37               diff exp got
38 }
39
40 #------------------------------------------------------------------
41
42 will_test 'leading spaces'
43
44 cat > input <<END
45   1
46    2
47 3
48  4
49 ${tab}5
50 ${tab}  6
51   6${sp}
52 7${sp}
53   8${sp}${sp}
54 9${sp}${sp}
55   10${tab}
56 11${tab}
57   12${sp}${tab}
58 13${sp}${tab}
59   14 this${tab}with${tab}multiple fields${sp}
60 15 and   ${tab}${tab}this too${tab}
61  16 and also this
62 ${sp}${sp}
63 ${sp}
64 ${tab}
65
66 last line
67 END
68
69 cat > exp <<END
70 1
71  2
72 3
73  4
74 ${tab}5
75 ${tab}  6
76 6${sp}
77 7${sp}
78 8${sp}${sp}
79 9${sp}${sp}
80 10${tab}
81 11${tab}
82 12${sp}${tab}
83 13${sp}${tab}
84 14 this${tab}with${tab}multiple fields${sp}
85 15 and   ${tab}${tab}this too${tab}
86  16 and also this
87
88 ${sp}
89 ${tab}
90
91 last line
92 END
93
94 do_check
95
96 #------------------------------------------------------------------
97
98 will_test 'leading tab'
99
100 cat > input <<END
101 ${tab}1
102 ${tab} 2
103 3
104  4
105   5
106     6
107         7
108  ${tab}8
109 ${tab}${tab}9
110 ${tab}10${tab}
111 ${tab}11${sp}
112 12${tab}
113 13${sp}
114 ${tab}14 this  with${tab}multiple fields${sp}
115 15 and   ${tab}${tab}this too${tab}
116  16 and also this
117 ${tab}
118 ${sp}
119 ${sp}${tab}
120
121 last line
122 END
123
124 cat > exp <<END
125 1
126  2
127 3
128  4
129   5
130     6
131         7
132  ${tab}8
133 ${tab}9
134 10${tab}
135 11${sp}
136 12${tab}
137 13${sp}
138 14 this  with${tab}multiple fields${sp}
139 15 and   ${tab}${tab}this too${tab}
140  16 and also this
141
142 ${sp}
143 ${sp}${tab}
144
145 last line
146 END
147
148 do_check "leading tab"
149
150 #------------------------------------------------------------------
151
152 will_test 'no leading whitespace'
153
154 cat > input <<END
155 1
156  2
157   3
158         4
159 ${tab}5
160 ${tab} 6
161  ${tab}7
162 ${tab}${tab}8
163 9${sp}
164  10${tab}
165 ${tab}10${sp}${sp}
166 14 this with${tab}multiple  fields${sp}
167  15 and this too${tab}
168 ${tab}16 and also this
169 ${tab}
170 ${sp}
171
172 last line
173 END
174
175 cp input exp
176
177 do_check
178
179 #------------------------------------------------------------------
180
181 will_test 'leading empty lines ignored (1)'
182
183 cat > input <<END
184
185
186  foo
187  bar
188    quux
189 END
190
191 cat > exp <<END
192
193
194 foo
195 bar
196   quux
197 END
198
199 do_check
200
201 #------------------------------------------------------------------
202
203 will_test 'leading empty lines ignored (2)'
204
205 cat > input <<END
206
207
208 foo
209 bar
210    quux
211 END
212
213 cat > exp <<END
214
215
216 foo
217 bar
218    quux
219 END
220
221 do_check
222
223 #------------------------------------------------------------------
224
225 will_test 'more elaborated parallel use'
226
227 cat > input <<END
228   x
229   ${tab}y
230   z
231   ${tab}a
232   ${tab} b
233 ${tab}c
234    ${tab}d
235  ${tab}e
236   ${tab}${tab}f
237 END
238
239 cat > exp <<END
240 y
241 z
242 a
243  b
244 c
245  ${tab}d
246  ${tab}e
247 ${tab}f
248 END
249
250 command_ok_ "$tst [exit status]" \
251             eval 'unindent input | sed 1d | unindent > got'
252
253 command_ok_ "$tst [output]" diff exp got
254
255 :