annotate src/testdir/test_jumplist.vim @ 19694:196dcd448100

Added tag v8.2.0403 for changeset 9fbeb3bdf49e51b60c5eb575d4399ecbff0100b8
author Bram Moolenaar <Bram@vim.org>
date Thu, 19 Mar 2020 12:45:05 +0100
parents 4935244c1128
children 08940efa6b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the jumplist functionality
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Tests for the getjumplist() function
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 func Test_getjumplist()
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 if !has("jumplist")
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 return
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 endif
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 %bwipe
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 clearjumps
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_equal([[], 0], getjumplist())
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal([[], 0], getjumplist(1))
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal([[], 0], getjumplist(1, 1))
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal([], getjumplist(100))
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal([], getjumplist(1, 100))
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let lines = []
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 for i in range(1, 100)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call add(lines, "Line " . i)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endfor
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call writefile(lines, "Xtest")
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " Jump around and create a jump list
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 edit Xtest
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let bnr = bufnr('%')
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 normal 50%
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 normal G
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 normal gg
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
31 let expected = [[
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0},
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
34 \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 3]
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
35 call assert_equal(expected, getjumplist())
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
36 " jumplist doesn't change in between calls
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
37 call assert_equal(expected, getjumplist())
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 " Traverse the jump list and verify the results
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 5
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 exe "normal \<C-O>"
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 15788
diff changeset
42 call assert_equal(2, 1->getjumplist()[1])
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 exe "normal 2\<C-O>"
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal(0, getjumplist(1, 1)[1])
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 exe "normal 3\<C-I>"
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal(3, getjumplist()[1])
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 exe "normal \<C-O>"
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 normal 20%
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
49 let expected = [[
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0},
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0},
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
53 \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4]
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
54 call assert_equal(expected, getjumplist())
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
55 " jumplist doesn't change in between calls
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 13248
diff changeset
56 call assert_equal(expected, getjumplist())
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 let l = getjumplist()
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call test_garbagecollect_now()
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
60 call assert_equal(4, l[1])
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 clearjumps
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call test_garbagecollect_now()
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
63 call assert_equal(4, l[1])
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call delete("Xtest")
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 endfunc