Mercurial > vim
comparison src/testdir/test_xxd.vim @ 30869:bff3fa5f4c74 v9.0.0769
patch 9.0.0769: too many delete() calls in tests
Commit: https://github.com/vim/vim/commit/db4c94788ad70118fa1ccc5fbc821757350ac771
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 15 22:06:06 2022 +0100
patch 9.0.0769: too many delete() calls in tests
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Oct 2022 23:15:04 +0200 |
parents | 948c947cb1ed |
children | dbec60b8c253 |
comparison
equal
deleted
inserted
replaced
30868:ae65ad930e86 | 30869:bff3fa5f4c74 |
---|---|
272 endfunc | 272 endfunc |
273 | 273 |
274 func Test_xxd_patch() | 274 func Test_xxd_patch() |
275 let cmd1 = 'silent !' .. s:xxd_cmd .. ' -r Xxxdin Xxxdfile' | 275 let cmd1 = 'silent !' .. s:xxd_cmd .. ' -r Xxxdin Xxxdfile' |
276 let cmd2 = 'silent !' .. s:xxd_cmd .. ' -g1 Xxxdfile > Xxxdout' | 276 let cmd2 = 'silent !' .. s:xxd_cmd .. ' -g1 Xxxdfile > Xxxdout' |
277 call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin') | 277 call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin', 'D') |
278 call writefile(['::::::::'], 'Xxxdfile') | 278 call writefile(['::::::::'], 'Xxxdfile', 'D') |
279 exe cmd1 | 279 exe cmd1 |
280 exe cmd2 | 280 exe cmd2 |
281 call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42 ::AA::::BB'], readfile('Xxxdout')) | 281 call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42 ::AA::::BB'], readfile('Xxxdout')) |
282 | 282 |
283 call writefile(["2: 43 43 ", "8: 44 44"], 'Xxxdin') | 283 call writefile(["2: 43 43 ", "8: 44 44"], 'Xxxdin') |
304 call writefile(["2: 45 45 ", "0a: 46 46"], 'Xxxdin') | 304 call writefile(["2: 45 45 ", "0a: 46 46"], 'Xxxdin') |
305 exe cmd1 | 305 exe cmd1 |
306 exe cmd2 | 306 exe cmd2 |
307 call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 42 44 46 46 ::EE::::BDFF'], readfile('Xxxdout')) | 307 call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 42 44 46 46 ::EE::::BDFF'], readfile('Xxxdout')) |
308 | 308 |
309 call delete('Xxxdin') | |
310 call delete('Xxxdfile') | |
311 call delete('Xxxdout') | 309 call delete('Xxxdout') |
312 endfunc | 310 endfunc |
313 | 311 |
314 " Various ways with wrong arguments that trigger the usage output. | 312 " Various ways with wrong arguments that trigger the usage output. |
315 func Test_xxd_usage() | 313 func Test_xxd_usage() |
367 endfunc | 365 endfunc |
368 | 366 |
369 " -c0 selects the format specific default column value, as if no -c was given | 367 " -c0 selects the format specific default column value, as if no -c was given |
370 " except for -ps, where it disables extra newlines | 368 " except for -ps, where it disables extra newlines |
371 func Test_xxd_c0_is_def_cols() | 369 func Test_xxd_c0_is_def_cols() |
372 call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin') | 370 call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin', 'D') |
373 for cols in ['-c0', '-c 0', '-cols 0'] | 371 for cols in ['-c0', '-c 0', '-cols 0'] |
374 for fmt in ['', '-b', '-e', '-i'] | 372 for fmt in ['', '-b', '-e', '-i'] |
375 exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1' | 373 exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1' |
376 exe 'r! ' . s:xxd_cmd . ' ' . cols . ' ' . fmt ' Xxdin > Xxdout2' | 374 exe 'r! ' . s:xxd_cmd . ' ' . cols . ' ' . fmt ' Xxdin > Xxdout2' |
377 call assert_equalfile('Xxdout1', 'Xxdout2') | 375 call assert_equalfile('Xxdout1', 'Xxdout2') |
378 endfor | 376 endfor |
379 endfor | 377 endfor |
380 call delete('Xxdin') | |
381 call delete('Xxdout1') | 378 call delete('Xxdout1') |
382 call delete('Xxdout2') | 379 call delete('Xxdout2') |
383 endfunc | 380 endfunc |
384 | 381 |
385 " all output in a single line for -c0 -ps | 382 " all output in a single line for -c0 -ps |
389 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", | 386 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", |
390 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", | 387 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", |
391 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", | 388 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", |
392 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", | 389 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", |
393 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"], | 390 \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"], |
394 \ 'Xxdin') | 391 \ 'Xxdin', 'D') |
395 for cols in ['-c0', '-c 0', '-cols 0'] | 392 for cols in ['-c0', '-c 0', '-cols 0'] |
396 exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin' | 393 exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin' |
397 " output seems to start in line 2 | 394 " output seems to start in line 2 |
398 let out = join(getline(2, '$')) | 395 let out = join(getline(2, '$')) |
399 bwipe! | 396 bwipe! |
400 " newlines in xxd output result in spaces in the string variable out | 397 " newlines in xxd output result in spaces in the string variable out |
401 call assert_notmatch(" ", out) | 398 call assert_notmatch(" ", out) |
402 " xxd output must be non-empty and comprise only lower case hex digits | 399 " xxd output must be non-empty and comprise only lower case hex digits |
403 call assert_match("^[0-9a-f][0-9a-f]*$", out) | 400 call assert_match("^[0-9a-f][0-9a-f]*$", out) |
404 endfor | 401 endfor |
405 call delete('Xxdin') | |
406 endfunc | 402 endfunc |
407 | 403 |
408 " vim: shiftwidth=2 sts=2 expandtab | 404 " vim: shiftwidth=2 sts=2 expandtab |