Mercurial > vim
comparison src/testdir/test_signs.vim @ 9816:74990ddf0813 v7.4.2183
commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 8 22:26:48 2016 +0200
patch 7.4.2183
Problem: Sign tests are old style.
Solution: Turn them into new style tests. (Dominique Pelle)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 08 Aug 2016 22:30:06 +0200 |
parents | |
children | 66f1cf5dd385 |
comparison
equal
deleted
inserted
replaced
9815:84d7ba2b2b16 | 9816:74990ddf0813 |
---|---|
1 " Test for signs | |
2 | |
3 if !has('signs') | |
4 finish | |
5 endif | |
6 | |
7 func Test_sign() | |
8 new | |
9 call setline(1, ['a', 'b', 'c', 'd']) | |
10 | |
11 sign define Sign1 text=x | |
12 sign define Sign2 text=y | |
13 | |
14 " Test listing signs. | |
15 let a=execute('sign list') | |
16 call assert_equal("\nsign Sign1 text=x \nsign Sign2 text=y ", a) | |
17 | |
18 let a=execute('sign list Sign1') | |
19 call assert_equal("\nsign Sign1 text=x ", a) | |
20 | |
21 " Place the sign at line 3,then check that we can jump to it. | |
22 exe 'sign place 42 line=3 name=Sign1 buffer=' . bufnr('') | |
23 1 | |
24 exe 'sign jump 42 buffer=' . bufnr('') | |
25 call assert_equal('c', getline('.')) | |
26 | |
27 " Can't change sign. | |
28 call assert_fails("exe 'sign place 43 name=Sign1 buffer=' . bufnr('')", 'E885:') | |
29 | |
30 let a=execute('sign place') | |
31 call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n line=3 id=42 name=Sign1\n", a) | |
32 | |
33 " Unplace the sign and try jumping to it again should now fail. | |
34 sign unplace 42 | |
35 1 | |
36 call assert_fails("exe 'sign jump 42 buffer=' . bufnr('')", 'E157:') | |
37 call assert_equal('a', getline('.')) | |
38 | |
39 " Unplace sign on current line. | |
40 exe 'sign place 43 line=4 name=Sign2 buffer=' . bufnr('') | |
41 4 | |
42 sign unplace | |
43 let a=execute('sign place') | |
44 call assert_equal("\n--- Signs ---\n", a) | |
45 | |
46 " Try again to unplace sign on current line, it should fail this time. | |
47 call assert_fails('sign unplace', 'E159:') | |
48 | |
49 " Unplace all signs. | |
50 exe 'sign place 42 line=3 name=Sign1 buffer=' . bufnr('') | |
51 sign unplace * | |
52 let a=execute('sign place') | |
53 call assert_equal("\n--- Signs ---\n", a) | |
54 | |
55 " After undefining the sign, we should no longer be able to place it. | |
56 sign undefine Sign1 | |
57 sign undefine Sign2 | |
58 call assert_fails("exe 'sign place 42 line=3 name=Sign1 buffer=' . bufnr('')", 'E155:') | |
59 | |
60 endfunc | |
61 | |
62 func Test_sign_completion() | |
63 sign define Sign1 text=x | |
64 sign define Sign2 text=y | |
65 | |
66 call feedkeys(":sign \<C-A>\<C-B>\"\<CR>", 'tx') | |
67 call assert_equal('"sign define jump list place undefine unplace', @:) | |
68 | |
69 call feedkeys(":sign define Sign \<C-A>\<C-B>\"\<CR>", 'tx') | |
70 call assert_equal('"sign define Sign icon= linehl= text= texthl=', @:) | |
71 | |
72 call feedkeys(":sign define Sign linehl=Spell\<C-A>\<C-B>\"\<CR>", 'tx') | |
73 call assert_equal('"sign define Sign linehl=SpellBad SpellCap SpellLocal SpellRare', @:) | |
74 | |
75 call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx') | |
76 call assert_equal('"sign undefine Sign1 Sign2', @:) | |
77 | |
78 call feedkeys(":sign place 1 \<C-A>\<C-B>\"\<CR>", 'tx') | |
79 call assert_equal('"sign place 1 buffer= file= line= name=', @:) | |
80 | |
81 call feedkeys(":sign place 1 name=\<C-A>\<C-B>\"\<CR>", 'tx') | |
82 call assert_equal('"sign place 1 name=Sign1 Sign2', @:) | |
83 | |
84 call feedkeys(":sign unplace 1 \<C-A>\<C-B>\"\<CR>", 'tx') | |
85 call assert_equal('"sign unplace 1 buffer= file=', @:) | |
86 | |
87 call feedkeys(":sign list \<C-A>\<C-B>\"\<CR>", 'tx') | |
88 call assert_equal('"sign list Sign1 Sign2', @:) | |
89 | |
90 call feedkeys(":sign jump 1 \<C-A>\<C-B>\"\<CR>", 'tx') | |
91 call assert_equal('"sign jump 1 buffer= file=', @:) | |
92 | |
93 sign undefine Sign1 | |
94 sign undefine Sign2 | |
95 | |
96 endfunc | |
97 | |
98 func Test_sign_invalid_commands() | |
99 call assert_fails('sign', 'E471:') | |
100 call assert_fails('sign xxx', 'E160:') | |
101 call assert_fails('sign define', 'E156:') | |
102 call assert_fails('sign undefine', 'E156:') | |
103 call assert_fails('sign list xxx', 'E155:') | |
104 call assert_fails('sign place 1 buffer=', 'E158:') | |
105 call assert_fails('sign define Sign2 text=', 'E239:') | |
106 endfunc |