Bram Moolenaar | e93e5a5 | 2019-02-15 20:22:38 +0100 | [diff] [blame] | 1 | " Test :wnext :wNext and :wprevious |
| 2 | |
| 3 | func Test_wnext() |
| 4 | args X1 X2 |
| 5 | |
| 6 | call setline(1, '1') |
| 7 | wnext |
| 8 | call assert_equal(['1'], readfile('X1')) |
| 9 | call assert_equal('X2', bufname('%')) |
| 10 | |
| 11 | call setline(1, '2') |
| 12 | call assert_fails('wnext', 'E165:') |
| 13 | call assert_equal(['2'], readfile('X2')) |
| 14 | call assert_equal('X2', bufname('%')) |
| 15 | |
| 16 | " Test :wnext with a single file. |
| 17 | args X1 |
| 18 | call assert_equal('X1', bufname('%')) |
| 19 | call assert_fails('wnext', 'E163:') |
| 20 | |
| 21 | " Test :wnext with a count. |
| 22 | args X1 X2 X3 |
| 23 | call assert_equal('X1', bufname('%')) |
| 24 | 2wnext |
| 25 | call assert_equal('X3', bufname('%')) |
| 26 | |
| 27 | " Test :wnext {file}. |
| 28 | args X1 X2 X3 |
| 29 | wnext X4 |
| 30 | call assert_equal(['1'], readfile('X4')) |
| 31 | call assert_equal('X2', bufname('%')) |
| 32 | call assert_fails('wnext X4', 'E13:') |
| 33 | call assert_equal(['1'], readfile('X4')) |
| 34 | wnext! X4 |
| 35 | call assert_equal(['2'], readfile('X4')) |
| 36 | call assert_equal('X3', bufname('%')) |
| 37 | |
| 38 | args X1 X2 |
| 39 | " Commented out as, E13 occurs on Windows instead of E17 |
| 40 | "call assert_fails('wnext .', 'E17:') |
| 41 | call assert_fails('wnext! .', 'E502:') |
| 42 | |
| 43 | %bwipe! |
| 44 | call delete('X1') |
| 45 | call delete('X2') |
| 46 | call delete('X3') |
| 47 | call delete('X4') |
| 48 | endfunc |
| 49 | |
| 50 | func Test_wprevious() |
| 51 | args X1 X2 |
| 52 | |
| 53 | next |
| 54 | call assert_equal('X2', bufname('%')) |
| 55 | call setline(1, '2') |
| 56 | wprevious |
| 57 | call assert_equal(['2'], readfile('X2')) |
| 58 | call assert_equal('X1', bufname('%')) |
| 59 | |
| 60 | call setline(1, '1') |
| 61 | call assert_fails('wprevious', 'E164:') |
| 62 | call assert_fails('wNext', 'E164:') |
| 63 | |
| 64 | " Test :wprevious with a single file. |
| 65 | args X1 |
| 66 | call assert_fails('wprevious', 'E163:') |
| 67 | call assert_fails('wNext', 'E163:') |
| 68 | |
| 69 | " Test :wprevious with a count. |
| 70 | args X1 X2 X3 |
| 71 | 2next |
| 72 | call setline(1, '3') |
| 73 | call assert_equal('X3', bufname('%')) |
| 74 | 2wprevious |
| 75 | call assert_equal('X1', bufname('%')) |
| 76 | call assert_equal(['3'], readfile('X3')) |
| 77 | |
| 78 | " Test :wprevious {file} |
| 79 | args X1 X2 X3 |
| 80 | 2next |
| 81 | call assert_equal('X3', bufname('%')) |
| 82 | wprevious X4 |
| 83 | call assert_equal(['3'], readfile('X4')) |
| 84 | call assert_equal('X2', bufname('%')) |
| 85 | call assert_fails('wprevious X4', 'E13:') |
| 86 | call assert_equal(['3'], readfile('X4')) |
| 87 | wprevious! X4 |
| 88 | call assert_equal(['2'], readfile('X4')) |
| 89 | call assert_equal('X1', bufname('%')) |
| 90 | |
| 91 | args X1 X2 |
| 92 | " Commented out as, E13 occurs on Windows instead of E17 |
| 93 | "call assert_fails('wprevious .', 'E17:') |
| 94 | call assert_fails('wprevious! .', 'E502:') |
| 95 | |
| 96 | %bwipe! |
| 97 | call delete('X1') |
| 98 | call delete('X2') |
| 99 | call delete('X3') |
| 100 | call delete('X4') |
| 101 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 102 | |
| 103 | " vim: shiftwidth=2 sts=2 expandtab |