Bram Moolenaar | 94f82cb | 2019-07-24 22:30:27 +0200 | [diff] [blame] | 1 | " Tests for various Ex commands. |
| 2 | |
| 3 | func Test_ex_delete() |
| 4 | new |
| 5 | call setline(1, ['a', 'b', 'c']) |
| 6 | 2 |
| 7 | " :dl is :delete with the "l" flag, not :dlist |
| 8 | .dl |
| 9 | call assert_equal(['a', 'c'], getline(1, 2)) |
| 10 | endfunc |
Bram Moolenaar | 0acae7a | 2019-08-06 21:29:29 +0200 | [diff] [blame] | 11 | |
| 12 | func Test_range_error() |
| 13 | call assert_fails(':.echo 1', 'E481:') |
| 14 | call assert_fails(':$echo 1', 'E481:') |
| 15 | call assert_fails(':1,2echo 1', 'E481:') |
| 16 | call assert_fails(':+1echo 1', 'E481:') |
| 17 | call assert_fails(':/1/echo 1', 'E481:') |
| 18 | call assert_fails(':\/echo 1', 'E481:') |
| 19 | normal vv |
| 20 | call assert_fails(":'<,'>echo 1", 'E481:') |
| 21 | endfunc |
Bram Moolenaar | 5241057 | 2019-10-27 05:12:45 +0100 | [diff] [blame] | 22 | |
| 23 | func Test_buffers_lastused() |
| 24 | call test_settime(localtime() - 2000) " middle |
| 25 | edit bufa |
| 26 | enew |
| 27 | call test_settime(localtime() - 10) " newest |
| 28 | edit bufb |
| 29 | enew |
| 30 | call test_settime(1550010000) " oldest |
| 31 | edit bufc |
| 32 | enew |
| 33 | call test_settime(0) |
| 34 | enew |
| 35 | |
| 36 | let ls = split(execute('buffers t', 'silent!'), '\n') |
| 37 | let bufs = ls->map({i,v->split(v, '"\s*')[1:2]}) |
| 38 | call assert_equal(['bufb', 'bufa', 'bufc'], bufs[1:]->map({i,v->v[0]})) |
| 39 | call assert_match('1[0-3] seconds ago', bufs[1][1]) |
| 40 | call assert_match('\d\d:\d\d:\d\d', bufs[2][1]) |
| 41 | call assert_match('2019/02/1\d \d\d:\d\d:00', bufs[3][1]) |
| 42 | |
| 43 | bwipeout bufa |
| 44 | bwipeout bufb |
| 45 | bwipeout bufc |
| 46 | endfunc |