comparison src/testdir/test_normal.vim @ 22524:1baf86830e44 v8.2.1810

patch 8.2.1810: some code in normal.c not covered by tests Commit: https://github.com/vim/vim/commit/d7e5e9430ae192c76f1f03c3ac53fae823d94c33 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 7 16:54:52 2020 +0200 patch 8.2.1810: some code in normal.c not covered by tests Problem: Some code in normal.c not covered by tests. Solution: Add normal mode tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7086)
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Oct 2020 17:00:04 +0200
parents 1503ecd54f8a
children 93f90f2ff4e9
comparison
equal deleted inserted replaced
22523:2d2f16db19ad 22524:1baf86830e44
115 115
116 set keymodel= 116 set keymodel=
117 50 117 50
118 call feedkeys("Vkk\<Up>yy", 'tx') 118 call feedkeys("Vkk\<Up>yy", 'tx')
119 call assert_equal(['47', '48', '49', '50'], getreg(0, 0, 1)) 119 call assert_equal(['47', '48', '49', '50'], getreg(0, 0, 1))
120
121 " Test for using special keys to start visual selection
122 %d
123 call setline(1, ['red fox tail', 'red fox tail', 'red fox tail'])
124 set keymodel=startsel
125 " Test for <S-PageUp> and <S-PageDown>
126 call cursor(1, 1)
127 call feedkeys("\<S-PageDown>y", 'xt')
128 call assert_equal([0, 1, 1, 0], getpos("'<"))
129 call assert_equal([0, 3, 1, 0], getpos("'>"))
130 call feedkeys("Gz\<CR>8|\<S-PageUp>y", 'xt')
131 call assert_equal([0, 2, 1, 0], getpos("'<"))
132 call assert_equal([0, 3, 8, 0], getpos("'>"))
133 " Test for <S-C-Home> and <S-C-End>
134 call cursor(2, 12)
135 call feedkeys("\<S-C-Home>y", 'xt')
136 call assert_equal([0, 1, 1, 0], getpos("'<"))
137 call assert_equal([0, 2, 12, 0], getpos("'>"))
138 call cursor(1, 4)
139 call feedkeys("\<S-C-End>y", 'xt')
140 call assert_equal([0, 1, 4, 0], getpos("'<"))
141 call assert_equal([0, 3, 13, 0], getpos("'>"))
142 " Test for <S-C-Left> and <S-C-Right>
143 call cursor(2, 5)
144 call feedkeys("\<S-C-Right>y", 'xt')
145 call assert_equal([0, 2, 5, 0], getpos("'<"))
146 call assert_equal([0, 2, 9, 0], getpos("'>"))
147 call cursor(2, 9)
148 call feedkeys("\<S-C-Left>y", 'xt')
149 call assert_equal([0, 2, 5, 0], getpos("'<"))
150 call assert_equal([0, 2, 9, 0], getpos("'>"))
151
152 set keymodel&
120 153
121 " clean up 154 " clean up
122 bw! 155 bw!
123 endfunc 156 endfunc
124 157
407 for i in range(1, 16) 440 for i in range(1, 16)
408 exe 'norm ' . i . '|' 441 exe 'norm ' . i . '|'
409 call assert_equal(expected[i], expand('<cexpr>'), 'i == ' . i) 442 call assert_equal(expected[i], expand('<cexpr>'), 'i == ' . i)
410 endfor 443 endfor
411 444
445 " Test for <cexpr> in state.val and ptr->val
446 call setline(1, 'x = state.val;')
447 call cursor(1, 10)
448 call assert_equal('state.val', expand('<cexpr>'))
449 call setline(1, 'x = ptr->val;')
450 call cursor(1, 9)
451 call assert_equal('ptr->val', expand('<cexpr>'))
452
412 if executable('echo') 453 if executable('echo')
413 " Test expand(`...`) i.e. backticks command expansion. 454 " Test expand(`...`) i.e. backticks command expansion.
414 call assert_equal('abcde', expand('`echo abcde`')) 455 call assert_equal('abcde', expand('`echo abcde`'))
415 endif 456 endif
416 457
417 " Test expand(`=...`) i.e. backticks expression expansion 458 " Test expand(`=...`) i.e. backticks expression expansion
418 call assert_equal('5', expand('`=2+3`')) 459 call assert_equal('5', expand('`=2+3`'))
419 call assert_equal('3.14', expand('`=3.14`')) 460 call assert_equal('3.14', expand('`=3.14`'))
420 461
421 " clean up 462 " clean up
463 bw!
464 endfunc
465
466 " Test for expand() in latin1 encoding
467 func Test_normal_expand_latin1()
468 new
469 let save_enc = &encoding
470 set encoding=latin1
471 call setline(1, 'val = item->color;')
472 call cursor(1, 11)
473 call assert_equal('color', expand("<cword>"))
474 call assert_equal('item->color', expand("<cexpr>"))
475 let &encoding = save_enc
422 bw! 476 bw!
423 endfunc 477 endfunc
424 478
425 func Test_normal11_showcmd() 479 func Test_normal11_showcmd()
426 " test for 'showcmd' 480 " test for 'showcmd'
444 call setline(1, ["\U2206"]) 498 call setline(1, ["\U2206"])
445 call feedkeys("ggv", 'xt') 499 call feedkeys("ggv", 'xt')
446 redraw! 500 redraw!
447 call assert_match('1-3$', Screenline(&lines)) 501 call assert_match('1-3$', Screenline(&lines))
448 call feedkeys("v", 'xt') 502 call feedkeys("v", 'xt')
503 " test for visually selecting the end of line
504 call setline(1, ["foobar"])
505 call feedkeys("$vl", 'xt')
506 redraw!
507 call assert_match('2$', Screenline(&lines))
508 call feedkeys("y", 'xt')
509 call assert_equal("r\n", @")
449 bw! 510 bw!
450 endfunc 511 endfunc
451 512
452 " Test for nv_error and normal command errors 513 " Test for nv_error and normal command errors
453 func Test_normal12_nv_error() 514 func Test_normal12_nv_error()
2018 " replace a tab character in visual mode 2079 " replace a tab character in visual mode
2019 %d 2080 %d
2020 call setline(1, ["a\tb", "c\td", "e\tf"]) 2081 call setline(1, ["a\tb", "c\td", "e\tf"])
2021 normal gglvjjrx 2082 normal gglvjjrx
2022 call assert_equal(['axx', 'xxx', 'xxf'], getline(1, '$')) 2083 call assert_equal(['axx', 'xxx', 'xxf'], getline(1, '$'))
2084
2085 " replace with a multibyte character (with multiple composing characters)
2086 %d
2087 new
2088 call setline(1, 'aaa')
2089 exe "normal $ra\u0328\u0301"
2090 call assert_equal("aaa\u0328\u0301", getline(1))
2023 2091
2024 " clean up 2092 " clean up
2025 set noautoindent 2093 set noautoindent
2026 bw! 2094 bw!
2027 endfunc 2095 endfunc