Mercurial > vim
annotate src/testdir/test_changelist.vim @ 28846:0541b9c09e21 v8.2.4946
patch 8.2.4946: Vim9: some code not covered by tests
Commit: https://github.com/vim/vim/commit/7f8a3b11bfc02f24dfd877d0a81392d679008180
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 12 22:03:01 2022 +0100
patch 8.2.4946: Vim9: some code not covered by tests
Problem: Vim9: some code not covered by tests.
Solution: Add a few more test cases. Remove dead code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 May 2022 23:15:03 +0200 |
parents | 1170b35651a5 |
children | 5baf5e50049b |
rev | line source |
---|---|
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for the changelist functionality |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Tests for the getchangelist() function |
28413
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
4 func Test_changelist_index() |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
5 edit Xfile1.txt |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
6 exe "normal iabc\<C-G>u\ndef\<C-G>u\nghi" |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
7 call assert_equal(3, getchangelist('%')[1]) |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
8 " Move one step back in the changelist. |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
9 normal 2g; |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
10 |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
11 hide edit Xfile2.txt |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
12 exe "normal iabcd\<C-G>u\ndefg\<C-G>u\nghij" |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
13 call assert_equal(3, getchangelist('%')[1]) |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
14 " Move to the beginning of the changelist. |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
15 normal 99g; |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
16 |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
17 " Check the changelist indices. |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
18 call assert_equal(0, getchangelist('%')[1]) |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
19 call assert_equal(1, getchangelist('#')[1]) |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
20 |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
21 bwipe! |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
22 call delete('Xfile1.txt') |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
23 call delete('Xfile2.txt') |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
24 endfunc |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
25 |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 func Test_getchangelist() |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 bwipe! |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 enew |
17857
4935244c1128
patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
13290
diff
changeset
|
29 call assert_equal([], 10->getchangelist()) |
4935244c1128
patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
13290
diff
changeset
|
30 call assert_equal([[], 0], getchangelist()) |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt') |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt') |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 edit Xfile1.txt |
28413
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
36 let buf_1 = bufnr() |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 exe "normal 1Goline\<C-G>u1.1" |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 exe "normal 3Goline\<C-G>u2.1" |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 exe "normal 5Goline\<C-G>u3.1" |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 normal g; |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call assert_equal([[ |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2], |
13290
3f3d9ed211b2
patch 8.0.1519: getchangelist() does not use argument as bufname()
Christian Brabandt <cb@256bit.org>
parents:
13280
diff
changeset
|
45 \ getchangelist('%')) |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 hide edit Xfile2.txt |
28413
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
48 let buf_2 = bufnr() |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 exe "normal 1GOline\<C-G>u1.0" |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 exe "normal 2Goline\<C-G>u2.0" |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 call assert_equal([[ |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], |
13290
3f3d9ed211b2
patch 8.0.1519: getchangelist() does not use argument as bufname()
Christian Brabandt <cb@256bit.org>
parents:
13280
diff
changeset
|
54 \ getchangelist('%')) |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 hide enew |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 call assert_equal([[ |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, |
28413
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
60 \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2], |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
61 \ getchangelist(buf_1)) |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 call assert_equal([[ |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, |
28413
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
64 \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], |
1170b35651a5
patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
65 \ getchangelist(buf_2)) |
13280
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 bwipe! |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call delete('Xfile1.txt') |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 call delete('Xfile2.txt') |
fbda23eb0996
patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 endfunc |
19625
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
71 |
f70a3c1000bb
patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
72 " vim: shiftwidth=2 sts=2 expandtab |