xref: /vim-8.2.3635/src/testdir/test_excmd.vim (revision 98056533)
1" Tests for various Ex commands.
2
3func 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))
10endfunc
11
12func 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:')
21endfunc
22
23func 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
46endfunc
47