comparison tests/test-diff-ignore-whitespace.t @ 12138:aff0b3947020

tests: unify test-diff-ignore-whitespace
author Adrian Buehlmann <adrian@cadifra.com>
date Mon, 30 Aug 2010 23:13:52 +0200
parents tests/test-diff-ignore-whitespace@6c82beaaa11a
children 8eb758ea738c
comparison
equal deleted inserted replaced
12137:e1814ff260c2 12138:aff0b3947020
1 GNU diff is the reference for all of these results.
2
3 Prepare tests:
4
5 $ echo '[alias]' >> $HGRCPATH
6 $ echo 'ndiff = diff --nodates' >> $HGRCPATH
7
8 $ hg init
9 $ printf 'hello world\ngoodbye world\n' >foo
10 $ hg ci -Amfoo -ufoo
11 adding foo
12
13
14 Test added blank lines:
15
16 $ printf '\nhello world\n\ngoodbye world\n\n' >foo
17
18 >>> two diffs showing three added lines <<<
19
20 $ hg ndiff
21 diff -r 540c40a65b78 foo
22 --- a/foo
23 +++ b/foo
24 @@ -1,2 +1,5 @@
25 +
26 hello world
27 +
28 goodbye world
29 +
30 $ hg ndiff -b
31 diff -r 540c40a65b78 foo
32 --- a/foo
33 +++ b/foo
34 @@ -1,2 +1,5 @@
35 +
36 hello world
37 +
38 goodbye world
39 +
40
41 >>> no diffs <<<
42
43 $ hg ndiff -B
44 $ hg ndiff -Bb
45
46
47 Test added horizontal space first on a line():
48
49 $ printf '\t hello world\ngoodbye world\n' >foo
50
51 >>> four diffs showing added space first on the first line <<<
52
53 $ hg ndiff
54 diff -r 540c40a65b78 foo
55 --- a/foo
56 +++ b/foo
57 @@ -1,2 +1,2 @@
58 -hello world
59 + hello world
60 goodbye world
61
62 $ hg ndiff -b
63 diff -r 540c40a65b78 foo
64 --- a/foo
65 +++ b/foo
66 @@ -1,2 +1,2 @@
67 -hello world
68 + hello world
69 goodbye world
70
71 $ hg ndiff -B
72 diff -r 540c40a65b78 foo
73 --- a/foo
74 +++ b/foo
75 @@ -1,2 +1,2 @@
76 -hello world
77 + hello world
78 goodbye world
79
80 $ hg ndiff -Bb
81 diff -r 540c40a65b78 foo
82 --- a/foo
83 +++ b/foo
84 @@ -1,2 +1,2 @@
85 -hello world
86 + hello world
87 goodbye world
88
89
90 Test added horizontal space last on a line:
91
92 $ printf 'hello world\t \ngoodbye world\n' >foo
93
94 >>> two diffs showing space appended to the first line <<<
95
96 $ hg ndiff
97 diff -r 540c40a65b78 foo
98 --- a/foo
99 +++ b/foo
100 @@ -1,2 +1,2 @@
101 -hello world
102 +hello world
103 goodbye world
104
105 $ hg ndiff -B
106 diff -r 540c40a65b78 foo
107 --- a/foo
108 +++ b/foo
109 @@ -1,2 +1,2 @@
110 -hello world
111 +hello world
112 goodbye world
113
114 >>> no diffs <<<
115
116 $ hg ndiff -b
117 $ hg ndiff -Bb
118
119
120 Test added horizontal space in the middle of a word:
121
122 $ printf 'hello world\ngood bye world\n' >foo
123
124 >>> four diffs showing space inserted into "goodbye" <<<
125
126 $ hg ndiff
127 diff -r 540c40a65b78 foo
128 --- a/foo
129 +++ b/foo
130 @@ -1,2 +1,2 @@
131 hello world
132 -goodbye world
133 +good bye world
134
135 $ hg ndiff -B
136 diff -r 540c40a65b78 foo
137 --- a/foo
138 +++ b/foo
139 @@ -1,2 +1,2 @@
140 hello world
141 -goodbye world
142 +good bye world
143
144 $ hg ndiff -b
145 diff -r 540c40a65b78 foo
146 --- a/foo
147 +++ b/foo
148 @@ -1,2 +1,2 @@
149 hello world
150 -goodbye world
151 +good bye world
152
153 $ hg ndiff -Bb
154 diff -r 540c40a65b78 foo
155 --- a/foo
156 +++ b/foo
157 @@ -1,2 +1,2 @@
158 hello world
159 -goodbye world
160 +good bye world
161
162
163 Test increased horizontal whitespace amount:
164
165 $ printf 'hello world\ngoodbye\t\t \tworld\n' >foo
166
167 >>> two diffs showing changed whitespace amount in the last line <<<
168
169 $ hg ndiff
170 diff -r 540c40a65b78 foo
171 --- a/foo
172 +++ b/foo
173 @@ -1,2 +1,2 @@
174 hello world
175 -goodbye world
176 +goodbye world
177
178 $ hg ndiff -B
179 diff -r 540c40a65b78 foo
180 --- a/foo
181 +++ b/foo
182 @@ -1,2 +1,2 @@
183 hello world
184 -goodbye world
185 +goodbye world
186
187 >>> no diffs <<<
188
189 $ hg ndiff -b
190 $ hg ndiff -Bb
191
192
193 Test added blank line with horizontal whitespace:
194
195 $ printf 'hello world\n \t\ngoodbye world\n' >foo
196
197 >>> three diffs showing added blank line with horizontal space <<<
198
199 $ hg ndiff
200 diff -r 540c40a65b78 foo
201 --- a/foo
202 +++ b/foo
203 @@ -1,2 +1,3 @@
204 hello world
205 +
206 goodbye world
207
208 $ hg ndiff -B
209 diff -r 540c40a65b78 foo
210 --- a/foo
211 +++ b/foo
212 @@ -1,2 +1,3 @@
213 hello world
214 +
215 goodbye world
216
217 $ hg ndiff -b
218 diff -r 540c40a65b78 foo
219 --- a/foo
220 +++ b/foo
221 @@ -1,2 +1,3 @@
222 hello world
223 +
224 goodbye world
225
226 >>> no diffs <<<
227
228 $ hg ndiff -Bb
229
230
231 Test added blank line with other whitespace:
232
233 $ printf 'hello world\n \t\ngoodbye world \n' >foo
234
235 >>> three diffs showing added blank line with other space <<<
236
237 $ hg ndiff
238 diff -r 540c40a65b78 foo
239 --- a/foo
240 +++ b/foo
241 @@ -1,2 +1,3 @@
242 -hello world
243 -goodbye world
244 +hello world
245 +
246 +goodbye world
247
248 $ hg ndiff -B
249 diff -r 540c40a65b78 foo
250 --- a/foo
251 +++ b/foo
252 @@ -1,2 +1,3 @@
253 -hello world
254 -goodbye world
255 +hello world
256 +
257 +goodbye world
258
259 $ hg ndiff -b
260 diff -r 540c40a65b78 foo
261 --- a/foo
262 +++ b/foo
263 @@ -1,2 +1,3 @@
264 hello world
265 +
266 goodbye world
267
268 >>> no diffs <<<
269
270 $ hg ndiff -Bb
271
272
273 Test whitespace changes:
274
275 $ printf 'helloworld\ngoodbye\tworld \n' >foo
276
277 >>> four diffs showing changed whitespace <<<
278
279 $ hg ndiff
280 diff -r 540c40a65b78 foo
281 --- a/foo
282 +++ b/foo
283 @@ -1,2 +1,2 @@
284 -hello world
285 -goodbye world
286 +helloworld
287 +goodbye world
288
289 $ hg ndiff -B
290 diff -r 540c40a65b78 foo
291 --- a/foo
292 +++ b/foo
293 @@ -1,2 +1,2 @@
294 -hello world
295 -goodbye world
296 +helloworld
297 +goodbye world
298
299 $ hg ndiff -b
300 diff -r 540c40a65b78 foo
301 --- a/foo
302 +++ b/foo
303 @@ -1,2 +1,2 @@
304 -hello world
305 +helloworld
306 goodbye world
307
308 $ hg ndiff -Bb
309 diff -r 540c40a65b78 foo
310 --- a/foo
311 +++ b/foo
312 @@ -1,2 +1,2 @@
313 -hello world
314 +helloworld
315 goodbye world
316
317 >>> no diffs <<<
318
319 $ hg ndiff -w
320
321
322 Test whitespace changes and blank lines:
323
324 $ printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo
325
326 >>> five diffs showing changed whitespace <<<
327
328 $ hg ndiff
329 diff -r 540c40a65b78 foo
330 --- a/foo
331 +++ b/foo
332 @@ -1,2 +1,5 @@
333 -hello world
334 -goodbye world
335 +helloworld
336 +
337 +
338 +
339 +goodbye world
340
341 $ hg ndiff -B
342 diff -r 540c40a65b78 foo
343 --- a/foo
344 +++ b/foo
345 @@ -1,2 +1,5 @@
346 -hello world
347 -goodbye world
348 +helloworld
349 +
350 +
351 +
352 +goodbye world
353
354 $ hg ndiff -b
355 diff -r 540c40a65b78 foo
356 --- a/foo
357 +++ b/foo
358 @@ -1,2 +1,5 @@
359 -hello world
360 +helloworld
361 +
362 +
363 +
364 goodbye world
365
366 $ hg ndiff -Bb
367 diff -r 540c40a65b78 foo
368 --- a/foo
369 +++ b/foo
370 @@ -1,2 +1,5 @@
371 -hello world
372 +helloworld
373 +
374 +
375 +
376 goodbye world
377
378 $ hg ndiff -w
379 diff -r 540c40a65b78 foo
380 --- a/foo
381 +++ b/foo
382 @@ -1,2 +1,5 @@
383 hello world
384 +
385 +
386 +
387 goodbye world
388
389 >>> no diffs <<<
390
391 $ hg ndiff -wB
392