Mercurial > vim
comparison src/testdir/test_python3.vim @ 19141:2c7d60b1bfa9 v8.2.0130
patch 8.2.0130: Python3 ranges are not tested
Commit: https://github.com/vim/vim/commit/904edabb64422467bf79f48f3a6305e0eddeea94
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 19 13:57:54 2020 +0100
patch 8.2.0130: Python3 ranges are not tested
Problem: Python3 ranges are not tested.
Solution: Add test. (Dominique Pelle, closes https://github.com/vim/vim/issues/5498)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Jan 2020 14:00:04 +0100 |
parents | 9bb2a4f6296a |
children | e7b4fff348dd |
comparison
equal
deleted
inserted
replaced
19140:210c031da828 | 19141:2c7d60b1bfa9 |
---|---|
185 py3 print('hello') | 185 py3 print('hello') |
186 endif | 186 endif |
187 | 187 |
188 set encoding=utf8 | 188 set encoding=utf8 |
189 endfunc | 189 endfunc |
190 | |
191 " Test range objects, see :help python-range | |
192 func Test_range() | |
193 new | |
194 py3 b = vim.current.buffer | |
195 | |
196 call setline(1, range(1, 6)) | |
197 py3 r = b.range(2, 4) | |
198 call assert_equal(6, py3eval('len(b)')) | |
199 call assert_equal(3, py3eval('len(r)')) | |
200 call assert_equal('3', py3eval('b[2]')) | |
201 call assert_equal('4', py3eval('r[2]')) | |
202 | |
203 call assert_fails('py3 r[3] = "x"', 'IndexError: line number out of range') | |
204 call assert_fails('py3 x = r[3]', 'IndexError: line number out of range') | |
205 call assert_fails('py3 r["a"] = "x"', 'TypeError') | |
206 call assert_fails('py3 x = r["a"]', 'TypeError') | |
207 | |
208 py3 del r[:] | |
209 call assert_equal(['1', '5', '6'], getline(1, '$')) | |
210 | |
211 %d | call setline(1, range(1, 6)) | |
212 py3 r = b.range(2, 5) | |
213 py3 del r[2] | |
214 call assert_equal(['1', '2', '3', '5', '6'], getline(1, '$')) | |
215 | |
216 %d | call setline(1, range(1, 6)) | |
217 py3 r = b.range(2, 4) | |
218 py3 vim.command("%d,%dnorm Ax" % (r.start + 1, r.end + 1)) | |
219 call assert_equal(['1', '2x', '3x', '4x', '5', '6'], getline(1, '$')) | |
220 | |
221 %d | call setline(1, range(1, 4)) | |
222 py3 r = b.range(2, 3) | |
223 py3 r.append(['a', 'b']) | |
224 call assert_equal(['1', '2', '3', 'a', 'b', '4'], getline(1, '$')) | |
225 py3 r.append(['c', 'd'], 0) | |
226 call assert_equal(['1', 'c', 'd', '2', '3', 'a', 'b', '4'], getline(1, '$')) | |
227 | |
228 %d | call setline(1, range(1, 5)) | |
229 py3 r = b.range(2, 4) | |
230 py3 r.append('a') | |
231 call assert_equal(['1', '2', '3', '4', 'a', '5'], getline(1, '$')) | |
232 py3 r.append('b', 1) | |
233 call assert_equal(['1', '2', 'b', '3', '4', 'a', '5'], getline(1, '$')) | |
234 | |
235 bwipe! | |
236 endfunc |