Mercurial > vim
comparison src/testdir/test_arglist.vim @ 30089:0a50e536de81
patch 9.0.0380: deleting files in tests is a hassle
Commit: https://github.com/vim/vim/commit/e1f3ab73bc7c4b3eee03b673c2983ed7eca6ea80
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 4 21:29:08 2022 +0100
patch 9.0.0380: deleting files in tests is a hassle
Problem: Deleting files in tests is a hassle.
Solution: Use the new 'D' flag of writefile().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 04 Sep 2022 22:30:03 +0200 |
parents | 2bdcce61a4e4 |
children | c684e9381495 |
comparison
equal
deleted
inserted
replaced
30088:4eac06fb0191 | 30089:0a50e536de81 |
---|---|
95 endfunc | 95 endfunc |
96 | 96 |
97 func Test_argadd_empty_curbuf() | 97 func Test_argadd_empty_curbuf() |
98 new | 98 new |
99 let curbuf = bufnr('%') | 99 let curbuf = bufnr('%') |
100 call writefile(['test', 'Xargadd'], 'Xargadd') | 100 call writefile(['test', 'Xargadd'], 'Xargadd', 'D') |
101 " must not re-use the current buffer. | 101 " must not re-use the current buffer. |
102 argadd Xargadd | 102 argadd Xargadd |
103 call assert_equal(curbuf, bufnr('%')) | 103 call assert_equal(curbuf, bufnr('%')) |
104 call assert_equal('', bufname('%')) | 104 call assert_equal('', bufname('%')) |
105 call assert_equal(1, '$'->line()) | 105 call assert_equal(1, '$'->line()) |
106 rew | 106 rew |
107 call assert_notequal(curbuf, '%'->bufnr()) | 107 call assert_notequal(curbuf, '%'->bufnr()) |
108 call assert_equal('Xargadd', '%'->bufname()) | 108 call assert_equal('Xargadd', '%'->bufname()) |
109 call assert_equal(2, line('$')) | 109 call assert_equal(2, line('$')) |
110 | 110 |
111 call delete('Xargadd') | |
112 %argd | 111 %argd |
113 bwipe! | 112 bwipe! |
114 endfunc | 113 endfunc |
115 | 114 |
116 func Init_abc() | 115 func Init_abc() |
504 endfunc | 503 endfunc |
505 | 504 |
506 " Test for autocommand that redefines the argument list, when doing ":all". | 505 " Test for autocommand that redefines the argument list, when doing ":all". |
507 func Test_arglist_autocmd() | 506 func Test_arglist_autocmd() |
508 autocmd BufReadPost Xxx2 next Xxx2 Xxx1 | 507 autocmd BufReadPost Xxx2 next Xxx2 Xxx1 |
509 call writefile(['test file Xxx1'], 'Xxx1') | 508 call writefile(['test file Xxx1'], 'Xxx1', 'D') |
510 call writefile(['test file Xxx2'], 'Xxx2') | 509 call writefile(['test file Xxx2'], 'Xxx2', 'D') |
511 call writefile(['test file Xxx3'], 'Xxx3') | 510 call writefile(['test file Xxx3'], 'Xxx3', 'D') |
512 | 511 |
513 new | 512 new |
514 " redefine arglist; go to Xxx1 | 513 " redefine arglist; go to Xxx1 |
515 next! Xxx1 Xxx2 Xxx3 | 514 next! Xxx1 Xxx2 Xxx3 |
516 " open window for all args; Reading Xxx2 will try to change the arglist and | 515 " open window for all args; Reading Xxx2 will try to change the arglist and |
522 wincmd w | 521 wincmd w |
523 call assert_equal('test file Xxx3', getline(1)) | 522 call assert_equal('test file Xxx3', getline(1)) |
524 | 523 |
525 autocmd! BufReadPost Xxx2 | 524 autocmd! BufReadPost Xxx2 |
526 enew! | only | 525 enew! | only |
527 call delete('Xxx1') | |
528 call delete('Xxx2') | |
529 call delete('Xxx3') | |
530 argdelete Xxx* | 526 argdelete Xxx* |
531 bwipe! Xxx1 Xxx2 Xxx3 | 527 bwipe! Xxx1 Xxx2 Xxx3 |
532 endfunc | 528 endfunc |
533 | 529 |
534 func Test_arg_all_expand() | 530 func Test_arg_all_expand() |
535 call writefile(['test file Xxx1'], 'Xx x') | 531 call writefile(['test file Xxx1'], 'Xx x', 'D') |
536 next notexist Xx\ x runtest.vim | 532 next notexist Xx\ x runtest.vim |
537 call assert_equal('notexist Xx\ x runtest.vim', expand('##')) | 533 call assert_equal('notexist Xx\ x runtest.vim', expand('##')) |
538 call delete('Xx x') | |
539 endfunc | 534 endfunc |
540 | 535 |
541 func Test_large_arg() | 536 func Test_large_arg() |
542 " Argument longer or equal to the number of columns used to cause | 537 " Argument longer or equal to the number of columns used to cause |
543 " access to invalid memory. | 538 " access to invalid memory. |