blob: 0880fce840b26a032442323ba2ed32cf93765d82 [file] [log] [blame]
Bram Moolenaar07ad8162018-02-13 13:59:59 +01001" Tests for the changelist functionality
2
3" Tests for the getchangelist() function
4func Test_getchangelist()
5 if !has("jumplist")
6 return
7 endif
8
9 bwipe!
10 enew
11 call assert_equal([], getchangelist(10))
12 call assert_equal([[], 0], getchangelist(bufnr('%')))
13
14 call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
15 call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
16
17 edit Xfile1.txt
18 exe "normal 1Goline\<C-G>u1.1"
19 exe "normal 3Goline\<C-G>u2.1"
20 exe "normal 5Goline\<C-G>u3.1"
21 normal g;
22 call assert_equal([[
23 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
24 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
25 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
26 \ getchangelist(bufnr('%')))
27
28 hide edit Xfile2.txt
29 exe "normal 1GOline\<C-G>u1.0"
30 exe "normal 2Goline\<C-G>u2.0"
31 call assert_equal([[
32 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
33 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
34 \ getchangelist(bufnr('%')))
35 hide enew
36
37 call assert_equal([[
38 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
39 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
40 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 3], getchangelist(2))
41 call assert_equal([[
42 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
43 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], getchangelist(3))
44
45 bwipe!
46 call delete('Xfile1.txt')
47 call delete('Xfile2.txt')
48endfunc