Mercurial > vim
annotate src/testdir/test_assert.vim @ 32669:448aef880252
normalize line endings
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 26 Jun 2023 09:54:34 +0200 |
parents | 088ca084ec37 |
children | 695b50472e85 |
rev | line source |
---|---|
32669
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
1 " Test that the methods used for testing work. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
2 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
3 source check.vim |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
4 source term_util.vim |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
5 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
6 func Test_assert_false() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
7 call assert_equal(0, assert_false(0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
8 call assert_equal(0, assert_false(v:false)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
9 call assert_equal(0, v:false->assert_false()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
10 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
11 call assert_equal(1, assert_false(123)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
12 call assert_match("Expected False but got 123", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
13 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
14 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
15 call assert_equal(1, 123->assert_false()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
16 call assert_match("Expected False but got 123", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
17 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
18 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
19 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
20 func Test_assert_true() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
21 call assert_equal(0, assert_true(1)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
22 call assert_equal(0, assert_true(123)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
23 call assert_equal(0, assert_true(v:true)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
24 call assert_equal(0, v:true->assert_true()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
25 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
26 call assert_equal(1, assert_true(0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
27 call assert_match("Expected True but got 0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
28 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
29 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
30 call assert_equal(1, 0->assert_true()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
31 call assert_match("Expected True but got 0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
32 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
33 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
34 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
35 func Test_assert_equal() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
36 let s = 'foo' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
37 call assert_equal(0, assert_equal('foo', s)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
38 let n = 4 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
39 call assert_equal(0, assert_equal(4, n)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
40 let l = [1, 2, 3] |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
41 call assert_equal(0, assert_equal([1, 2, 3], l)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
42 call assert_equal(test_null_list(), test_null_list()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
43 call assert_equal(test_null_list(), []) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
44 call assert_equal([], test_null_list()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
45 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
46 let s = 'foo' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
47 call assert_equal(1, assert_equal('bar', s)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
48 call assert_match("Expected 'bar' but got 'foo'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
49 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
50 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
51 call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
52 call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
53 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
54 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
55 " special characters are escaped |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
56 call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
57 call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''x''', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
58 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
59 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
60 " many composing characters are handled properly |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
61 call setline(1, ' ') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
62 norm 100grƯ€ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
63 call assert_equal(1, getline(1)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
64 call assert_match("Expected 1 but got '.* occurs 100 times]'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
65 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
66 bwipe! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
67 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
68 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
69 func Test_assert_equal_dict() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
70 call assert_equal(0, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 1})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
71 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
72 call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 3})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
73 call assert_match("Expected {'one': 1} but got {'one': 3} - 1 equal item omitted", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
74 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
75 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
76 call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 22, one: 11})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
77 call assert_match("Expected {'one': 1, 'two': 2} but got {'one': 11, 'two': 22}", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
78 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
79 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
80 call assert_equal(1, assert_equal(#{}, #{two: 2, one: 1})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
81 call assert_match("Expected {} but got {'one': 1, 'two': 2}", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
82 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
83 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
84 call assert_equal(1, assert_equal(#{two: 2, one: 1}, #{})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
85 call assert_match("Expected {'one': 1, 'two': 2} but got {}", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
86 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
87 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
88 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
89 func Test_assert_equalfile() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
90 call assert_equal(1, assert_equalfile('abcabc', 'xyzxyz')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
91 call assert_match("E485: Can't read file abcabc", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
92 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
93 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
94 let goodtext = ["one", "two", "three"] |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
95 call writefile(goodtext, 'Xone', 'D') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
96 call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
97 call assert_match("E485: Can't read file xyzxyz", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
98 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
99 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
100 call writefile(goodtext, 'Xtwo', 'D') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
101 call assert_equal(0, assert_equalfile('Xone', 'Xtwo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
102 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
103 call writefile([goodtext[0]], 'Xone') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
104 call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
105 call assert_match("first file is shorter", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
106 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
107 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
108 call writefile(goodtext, 'Xone') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
109 call writefile([goodtext[0]], 'Xtwo') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
110 call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
111 call assert_match("second file is shorter", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
112 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
113 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
114 call writefile(['1234X89'], 'Xone') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
115 call writefile(['1234Y89'], 'Xtwo') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
116 call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
117 call assert_match('difference at byte 4, line 1 after "1234X" vs "1234Y"', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
118 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
119 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
120 call writefile([repeat('x', 234) .. 'X'], 'Xone') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
121 call writefile([repeat('x', 234) .. 'Y'], 'Xtwo') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
122 call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
123 let xes = repeat('x', 134) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
124 call assert_match('difference at byte 234, line 1 after "' .. xes .. 'X" vs "' .. xes .. 'Y"', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
125 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
126 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
127 call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
128 call assert_match("a message: difference at byte 234, line 1 after", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
129 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
130 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
131 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
132 func Test_assert_notequal() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
133 let n = 4 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
134 call assert_equal(0, assert_notequal('foo', n)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
135 let s = 'foo' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
136 call assert_equal(0, assert_notequal([1, 2, 3], s)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
137 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
138 call assert_equal(1, assert_notequal('foo', s)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
139 call assert_match("Expected not equal to 'foo'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
140 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
141 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
142 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
143 func Test_assert_report() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
144 call assert_equal(1, assert_report('something is wrong')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
145 call assert_match('something is wrong', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
146 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
147 call assert_equal(1, 'also wrong'->assert_report()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
148 call assert_match('also wrong', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
149 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
150 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
151 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
152 func Test_assert_exception() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
153 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
154 nocommand |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
155 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
156 call assert_equal(0, assert_exception('E492:')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
157 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
158 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
159 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
160 nocommand |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
161 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
162 call assert_equal(1, assert_exception('E12345:')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
163 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
164 call assert_match("Expected 'E12345:' but got 'Vim:E492: ", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
165 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
166 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
167 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
168 nocommand |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
169 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
170 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
171 " illegal argument, get NULL for error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
172 call assert_equal(1, assert_exception([])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
173 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
174 call assert_equal(0, assert_exception('E730:')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
175 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
176 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
177 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
178 call assert_equal(1, assert_exception('E492:')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
179 call assert_match('v:exception is not set', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
180 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
181 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
182 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
183 func Test_wrong_error_type() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
184 let save_verrors = v:errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
185 let v:['errors'] = {'foo': 3} |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
186 call assert_equal('yes', 'no') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
187 let verrors = v:errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
188 let v:errors = save_verrors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
189 call assert_equal(type([]), type(verrors)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
190 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
191 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
192 func Test_compare_fail() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
193 let s:v = {} |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
194 let s:x = {"a": s:v} |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
195 let s:v["b"] = s:x |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
196 let s:w = {"c": s:x, "d": ''} |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
197 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
198 call assert_equal(s:w, '') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
199 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
200 call assert_equal(0, assert_exception('E724:')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
201 call assert_match("Expected NULL but got ''", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
202 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
203 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
204 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
205 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
206 func Test_match() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
207 call assert_equal(0, assert_match('^f.*b.*r$', 'foobar')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
208 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
209 call assert_equal(1, assert_match('bar.*foo', 'foobar')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
210 call assert_match("Pattern 'bar.*foo' does not match 'foobar'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
211 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
212 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
213 call assert_equal(1, assert_match('bar.*foo', 'foobar', 'wrong')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
214 call assert_match('wrong', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
215 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
216 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
217 call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
218 call assert_match('wrong', v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
219 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
220 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
221 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
222 func Test_notmatch() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
223 call assert_equal(0, assert_notmatch('foo', 'bar')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
224 call assert_equal(0, assert_notmatch('^foobar$', 'foobars')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
225 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
226 call assert_equal(1, assert_notmatch('foo', 'foobar')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
227 call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
228 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
229 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
230 call assert_equal(1, 'foobar'->assert_notmatch('foo')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
231 call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
232 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
233 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
234 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
235 func Test_assert_fail_fails() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
236 call assert_equal(1, assert_fails('xxx', 'E12345')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
237 call assert_match("Expected 'E12345' but got 'E492:", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
238 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
239 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
240 call assert_equal(1, assert_fails('xxx', 'E9876', 'stupid')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
241 call assert_match("stupid: Expected 'E9876' but got 'E492:", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
242 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
243 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
244 call assert_equal(1, assert_fails('xxx', ['E9876'])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
245 call assert_match("Expected 'E9876' but got 'E492:", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
246 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
247 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
248 call assert_equal(1, assert_fails('xxx', ['E492:', 'E9876'])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
249 call assert_match("Expected 'E9876' but got 'E492:", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
250 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
251 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
252 call assert_equal(1, assert_fails('echo', '', 'echo command')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
253 call assert_match("command did not fail: echo command", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
254 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
255 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
256 call assert_equal(1, 'echo'->assert_fails('', 'echo command')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
257 call assert_match("command did not fail: echo command", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
258 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
259 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
260 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
261 call assert_equal(1, assert_fails('xxx', [])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
262 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
263 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
264 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
265 call assert_match("E856: \"assert_fails()\" second argument", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
266 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
267 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
268 call assert_equal(1, assert_fails('xxx', ['1', '2', '3'])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
269 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
270 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
271 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
272 call assert_match("E856: \"assert_fails()\" second argument", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
273 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
274 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
275 call assert_equal(1, assert_fails('xxx', test_null_list())) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
276 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
277 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
278 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
279 call assert_match("E856: \"assert_fails()\" second argument", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
280 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
281 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
282 call assert_equal(1, assert_fails('xxx', [])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
283 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
284 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
285 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
286 call assert_match("E856: \"assert_fails()\" second argument", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
287 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
288 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
289 call assert_equal(1, assert_fails('xxx', #{one: 1})) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
290 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
291 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
292 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
293 call assert_match("E1222: String or List required for argument 2", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
294 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
295 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
296 call assert_equal(0, assert_fails('xxx', [#{one: 1}])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
297 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
298 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
299 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
300 call assert_match("E731: Using a Dictionary as a String", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
301 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
302 let exp = '' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
303 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
304 call assert_equal(0, assert_fails('xxx', ['E492', #{one: 1}])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
305 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
306 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
307 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
308 call assert_match("E731: Using a Dictionary as a String", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
309 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
310 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
311 call assert_equal(1, assert_fails('xxx', 'E492', '', 'burp')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
312 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
313 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
314 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
315 call assert_match("E1210: Number required for argument 4", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
316 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
317 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
318 call assert_equal(1, assert_fails('xxx', 'E492', '', 54, 123)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
319 catch |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
320 let exp = v:exception |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
321 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
322 call assert_match("E1174: String required for argument 5", exp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
323 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
324 call assert_equal(1, assert_fails('c0', ['', '\(.\)\1'])) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
325 call assert_match("Expected '\\\\\\\\(.\\\\\\\\)\\\\\\\\1' but got 'E939: Positive count required: c0': c0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
326 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
327 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
328 " Test for matching the line number and the script name in an error message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
329 call writefile(['', 'call Xnonexisting()'], 'Xassertfails.vim', 'D') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
330 call assert_fails('source Xassertfails.vim', 'E117:', '', 10) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
331 call assert_match("Expected 10 but got 2", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
332 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
333 call assert_fails('source Xassertfails.vim', 'E117:', '', 2, 'Xabc') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
334 call assert_match("Expected 'Xabc' but got .*Xassertfails.vim", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
335 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
336 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
337 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
338 func Test_assert_wrong_arg_emsg_off() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
339 CheckFeature folding |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
340 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
341 new |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
342 call setline(1, ['foo', 'bar']) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
343 1,2fold |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
344 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
345 " This used to crash Vim |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
346 let &l:foldtext = 'assert_match({}, {})' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
347 redraw! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
348 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
349 let &l:foldtext = 'assert_equalfile({}, {})' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
350 redraw! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
351 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
352 bwipe! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
353 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
354 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
355 func Test_assert_fails_in_try_block() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
356 try |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
357 call assert_equal(0, assert_fails('throw "error"')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
358 endtry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
359 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
360 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
361 " Test that assert_fails() in a timer does not cause a hit-enter prompt. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
362 " Requires using a terminal, in regular tests the hit-enter prompt won't be |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
363 " triggered. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
364 func Test_assert_fails_in_timer() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
365 CheckRunVimInTerminal |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
366 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
367 let buf = RunVimInTerminal('', {'rows': 6}) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
368 let cmd = ":call timer_start(0, {-> assert_fails('call', 'E471:')})" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
369 call term_sendkeys(buf, cmd) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
370 call WaitForAssert({-> assert_equal(cmd, term_getline(buf, 6))}) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
371 call term_sendkeys(buf, "\<CR>") |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
372 call TermWait(buf, 100) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
373 call assert_match('E471: Argument required', term_getline(buf, 6)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
374 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
375 call StopVimInTerminal(buf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
376 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
377 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
378 func Test_assert_beeps() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
379 new |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
380 call assert_equal(0, assert_beeps('normal h')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
381 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
382 call assert_equal(1, assert_beeps('normal 0')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
383 call assert_match("command did not beep: normal 0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
384 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
385 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
386 call assert_equal(0, 'normal h'->assert_beeps()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
387 call assert_equal(1, 'normal 0'->assert_beeps()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
388 call assert_match("command did not beep: normal 0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
389 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
390 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
391 bwipe |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
392 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
393 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
394 func Test_assert_nobeep() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
395 call assert_equal(1, assert_nobeep('normal! cr')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
396 call assert_match("command did beep: normal! cr", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
397 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
398 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
399 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
400 func Test_assert_inrange() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
401 call assert_equal(0, assert_inrange(7, 7, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
402 call assert_equal(0, assert_inrange(5, 7, 5)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
403 call assert_equal(0, assert_inrange(5, 7, 6)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
404 call assert_equal(0, assert_inrange(5, 7, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
405 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
406 call assert_equal(1, assert_inrange(5, 7, 4)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
407 call assert_match("Expected range 5 - 7, but got 4", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
408 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
409 call assert_equal(1, assert_inrange(5, 7, 8)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
410 call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
411 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
412 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
413 call assert_equal(0, 5->assert_inrange(5, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
414 call assert_equal(0, 7->assert_inrange(5, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
415 call assert_equal(1, 8->assert_inrange(5, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
416 call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
417 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
418 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
419 call assert_fails('call assert_inrange(1, 1)', 'E119:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
420 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
421 call assert_equal(0, assert_inrange(7.0, 7, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
422 call assert_equal(0, assert_inrange(7, 7.0, 7)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
423 call assert_equal(0, assert_inrange(7, 7, 7.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
424 call assert_equal(0, assert_inrange(5, 7, 5.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
425 call assert_equal(0, assert_inrange(5, 7, 6.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
426 call assert_equal(0, assert_inrange(5, 7, 7.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
427 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
428 call assert_equal(1, assert_inrange(5, 7, 4.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
429 call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
430 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
431 call assert_equal(1, assert_inrange(5, 7, 8.0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
432 call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
433 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
434 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
435 " Use a custom message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
436 call assert_equal(1, assert_inrange(5, 7, 8, "Higher")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
437 call assert_match("Higher: Expected range 5 - 7, but got 8", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
438 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
439 call assert_equal(1, assert_inrange(5, 7, 8.0, "Higher")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
440 call assert_match("Higher: Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
441 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
442 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
443 " Invalid arguments |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
444 call assert_fails("call assert_inrange([], 2, 3)", 'E1219:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
445 call assert_fails("call assert_inrange(1, [], 3)", 'E1219:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
446 call assert_fails("call assert_inrange(1, 2, [])", 'E1219:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
447 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
448 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
449 func Test_assert_with_msg() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
450 call assert_equal('foo', 'bar', 'testing') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
451 call assert_match("testing: Expected 'foo' but got 'bar'", v:errors[0]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
452 call remove(v:errors, 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
453 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
454 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
455 func Test_override() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
456 call test_override('char_avail', 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
457 eval 1->test_override('redraw') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
458 call test_override('ALL', 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
459 call assert_fails("call test_override('xxx', 1)", 'E475:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
460 call assert_fails("call test_override('redraw', 'yes')", 'E1210:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
461 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
462 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
463 func Test_mouse_position() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
464 let save_mouse = &mouse |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
465 set mouse=a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
466 new |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
467 call setline(1, ['line one', 'line two']) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
468 call assert_equal([0, 1, 1, 0], getpos('.')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
469 call test_setmouse(1, 5) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
470 call feedkeys("\<LeftMouse>", "xt") |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
471 call assert_equal([0, 1, 5, 0], getpos('.')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
472 call test_setmouse(2, 20) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
473 call feedkeys("\<LeftMouse>", "xt") |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
474 call assert_equal([0, 2, 8, 0], getpos('.')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
475 call test_setmouse(5, 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
476 call feedkeys("\<LeftMouse>", "xt") |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
477 call assert_equal([0, 2, 1, 0], getpos('.')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
478 call assert_fails('call test_setmouse("", 2)', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
479 call assert_fails('call test_setmouse(1, "")', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
480 bwipe! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
481 let &mouse = save_mouse |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
482 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
483 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
484 func Test_user_is_happy() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
485 smile |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
486 sleep 300m |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
487 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
488 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
489 " Test for the test_alloc_fail() function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
490 func Test_test_alloc_fail() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
491 call assert_fails('call test_alloc_fail([], 1, 1)', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
492 call assert_fails('call test_alloc_fail(10, [], 1)', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
493 call assert_fails('call test_alloc_fail(10, 1, [])', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
494 call assert_fails('call test_alloc_fail(999999, 1, 1)', 'E474:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
495 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
496 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
497 " Test for the test_option_not_set() function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
498 func Test_test_option_not_set() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
499 call assert_fails('call test_option_not_set("Xinvalidopt")', 'E475:') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
500 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
501 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
502 " Must be last. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
503 func Test_zz_quit_detected() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
504 " Verify that if a test function ends Vim the test script detects this. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
505 quit |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
506 endfunc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
507 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32359
diff
changeset
|
508 " vim: shiftwidth=2 sts=2 expandtab |