Bram Moolenaar | c9630d2 | 2020-06-13 13:20:48 +0200 | [diff] [blame] | 1 | " Test for various 'cpoptions' (cpo) flags |
| 2 | |
| 3 | source check.vim |
| 4 | source view_util.vim |
| 5 | |
| 6 | " Test for the 'a' flag in 'cpo'. Reading a file should set the alternate |
| 7 | " file name. |
| 8 | func Test_cpo_a() |
| 9 | let save_cpo = &cpo |
| 10 | call writefile(['one'], 'Xfile') |
| 11 | " Wipe out all the buffers, so that the alternate file is empty |
| 12 | edit Xfoo | %bw |
| 13 | set cpo-=a |
| 14 | new |
| 15 | read Xfile |
| 16 | call assert_equal('', @#) |
| 17 | %d |
| 18 | set cpo+=a |
| 19 | read Xfile |
| 20 | call assert_equal('Xfile', @#) |
| 21 | close! |
| 22 | call delete('Xfile') |
| 23 | let &cpo = save_cpo |
| 24 | endfunc |
| 25 | |
| 26 | " Test for the 'A' flag in 'cpo'. Writing a file should set the alternate |
| 27 | " file name. |
| 28 | func Test_cpo_A() |
| 29 | let save_cpo = &cpo |
| 30 | " Wipe out all the buffers, so that the alternate file is empty |
| 31 | edit Xfoo | %bw |
| 32 | set cpo-=A |
| 33 | new Xfile1 |
| 34 | write Xfile2 |
| 35 | call assert_equal('', @#) |
| 36 | %bw |
| 37 | call delete('Xfile2') |
| 38 | new Xfile1 |
| 39 | set cpo+=A |
| 40 | write Xfile2 |
| 41 | call assert_equal('Xfile2', @#) |
| 42 | close! |
| 43 | call delete('Xfile2') |
| 44 | let &cpo = save_cpo |
| 45 | endfunc |
| 46 | |
| 47 | " Test for the 'b' flag in 'cpo'. "\|" at the end of a map command is |
| 48 | " recognized as the end of the map. |
| 49 | func Test_cpo_b() |
| 50 | let save_cpo = &cpo |
| 51 | set cpo+=b |
| 52 | nnoremap <F5> :pwd\<CR>\|let i = 1 |
| 53 | call assert_equal(':pwd\<CR>\', maparg('<F5>')) |
| 54 | nunmap <F5> |
| 55 | exe "nnoremap <F5> :pwd\<C-V>|let i = 1" |
| 56 | call assert_equal(':pwd|let i = 1', maparg('<F5>')) |
| 57 | nunmap <F5> |
| 58 | set cpo-=b |
| 59 | nnoremap <F5> :pwd\<CR>\|let i = 1 |
| 60 | call assert_equal(':pwd\<CR>|let i = 1', maparg('<F5>')) |
| 61 | let &cpo = save_cpo |
| 62 | nunmap <F5> |
| 63 | endfunc |
| 64 | |
| 65 | " Test for the 'c' flag in 'cpo'. |
| 66 | func Test_cpo_c() |
| 67 | let save_cpo = &cpo |
| 68 | set cpo+=c |
| 69 | new |
| 70 | call setline(1, ' abababababab') |
| 71 | exe "normal gg/abab\<CR>" |
| 72 | call assert_equal(3, searchcount().total) |
| 73 | set cpo-=c |
| 74 | exe "normal gg/abab\<CR>" |
| 75 | call assert_equal(5, searchcount().total) |
| 76 | close! |
| 77 | let &cpo = save_cpo |
| 78 | endfunc |
| 79 | |
| 80 | " Test for the 'C' flag in 'cpo' (line continuation) |
| 81 | func Test_cpo_C() |
| 82 | let save_cpo = &cpo |
| 83 | call writefile(['let l = [', '\ 1,', '\ 2]'], 'Xfile') |
| 84 | set cpo-=C |
| 85 | source Xfile |
| 86 | call assert_equal([1, 2], g:l) |
| 87 | set cpo+=C |
| 88 | call assert_fails('source Xfile', 'E10:') |
| 89 | call delete('Xfile') |
| 90 | let &cpo = save_cpo |
| 91 | endfunc |
| 92 | |
| 93 | " Test for the 'd' flag in 'cpo' (tags relative to the current file) |
| 94 | func Test_cpo_d() |
| 95 | let save_cpo = &cpo |
| 96 | call mkdir('Xdir') |
| 97 | call writefile(["one\tXfile1\t/^one$/"], 'tags') |
| 98 | call writefile(["two\tXfile2\t/^two$/"], 'Xdir/tags') |
| 99 | set tags=./tags |
| 100 | set cpo-=d |
| 101 | edit Xdir/Xfile |
| 102 | call assert_equal('two', taglist('.*')[0].name) |
| 103 | set cpo+=d |
| 104 | call assert_equal('one', taglist('.*')[0].name) |
| 105 | %bw! |
| 106 | call delete('tags') |
| 107 | call delete('Xdir', 'rf') |
| 108 | set tags& |
| 109 | let &cpo = save_cpo |
| 110 | endfunc |
| 111 | |
| 112 | " Test for the 'D' flag in 'cpo' (digraph after a r, f or t) |
| 113 | func Test_cpo_D() |
| 114 | CheckFeature digraphs |
| 115 | let save_cpo = &cpo |
| 116 | new |
| 117 | set cpo-=D |
| 118 | call setline(1, 'abcdefgh|') |
| 119 | exe "norm! 1gg0f\<c-k>!!" |
| 120 | call assert_equal(9, col('.')) |
| 121 | set cpo+=D |
| 122 | exe "norm! 1gg0f\<c-k>!!" |
| 123 | call assert_equal(1, col('.')) |
| 124 | set cpo-=D |
| 125 | close! |
| 126 | let &cpo = save_cpo |
| 127 | endfunc |
| 128 | |
| 129 | " Test for the 'e' flag in 'cpo' |
| 130 | func Test_cpo_e() |
| 131 | let save_cpo = &cpo |
| 132 | let @a='let i = 45' |
| 133 | set cpo+=e |
| 134 | call feedkeys(":@a\<CR>", 'xt') |
| 135 | call assert_equal(45, i) |
| 136 | set cpo-=e |
| 137 | call feedkeys(":@a\<CR>6\<CR>", 'xt') |
| 138 | call assert_equal(456, i) |
| 139 | let &cpo = save_cpo |
| 140 | endfunc |
| 141 | |
| 142 | " Test for the 'E' flag in 'cpo' with yank, change, delete, etc. operators |
| 143 | func Test_cpo_E() |
| 144 | new |
| 145 | call setline(1, '') |
| 146 | set cpo+=E |
| 147 | " yank an empty line |
| 148 | call assert_beeps('normal "ayl') |
| 149 | " change an empty line |
| 150 | call assert_beeps('normal lcTa') |
| 151 | " delete an empty line |
| 152 | call assert_beeps('normal D') |
| 153 | call assert_beeps('normal dl') |
| 154 | call assert_equal('', getline(1)) |
| 155 | " change case of an empty line |
| 156 | call assert_beeps('normal gul') |
| 157 | call assert_beeps('normal gUl') |
| 158 | " replace a character |
| 159 | call assert_beeps('normal vrx') |
| 160 | " increment and decrement |
| 161 | call assert_beeps('exe "normal v\<C-A>"') |
| 162 | call assert_beeps('exe "normal v\<C-X>"') |
| 163 | set cpo-=E |
| 164 | close! |
| 165 | endfunc |
| 166 | |
| 167 | " Test for the 'f' flag in 'cpo' (read in an empty buffer sets the file name) |
| 168 | func Test_cpo_f() |
| 169 | let save_cpo = &cpo |
| 170 | new |
| 171 | set cpo-=f |
| 172 | read test_cpoptions.vim |
| 173 | call assert_equal('', @%) |
| 174 | %d |
| 175 | set cpo+=f |
| 176 | read test_cpoptions.vim |
| 177 | call assert_equal('test_cpoptions.vim', @%) |
| 178 | close! |
| 179 | let &cpo = save_cpo |
| 180 | endfunc |
| 181 | |
| 182 | " Test for the 'F' flag in 'cpo' (write in an empty buffer sets the file name) |
| 183 | func Test_cpo_F() |
| 184 | let save_cpo = &cpo |
| 185 | new |
| 186 | set cpo-=F |
| 187 | write Xfile |
| 188 | call assert_equal('', @%) |
| 189 | call delete('Xfile') |
| 190 | set cpo+=F |
| 191 | write Xfile |
| 192 | call assert_equal('Xfile', @%) |
| 193 | close! |
| 194 | call delete('Xfile') |
| 195 | let &cpo = save_cpo |
| 196 | endfunc |
| 197 | |
| 198 | " Test for the 'g' flag in 'cpo' (jump to line 1 when re-editing a file) |
| 199 | func Test_cpo_g() |
| 200 | let save_cpo = &cpo |
| 201 | new test_cpoptions.vim |
| 202 | set cpo-=g |
| 203 | normal 20G |
| 204 | edit |
| 205 | call assert_equal(20, line('.')) |
| 206 | set cpo+=g |
| 207 | edit |
| 208 | call assert_equal(1, line('.')) |
| 209 | close! |
| 210 | let &cpo = save_cpo |
| 211 | endfunc |
| 212 | |
| 213 | " Test for inserting text in a line with only spaces ('H' flag in 'cpoptions') |
| 214 | func Test_cpo_H() |
| 215 | let save_cpo = &cpo |
| 216 | new |
| 217 | set cpo-=H |
| 218 | call setline(1, ' ') |
| 219 | normal! Ia |
| 220 | call assert_equal(' a', getline(1)) |
| 221 | set cpo+=H |
| 222 | call setline(1, ' ') |
| 223 | normal! Ia |
| 224 | call assert_equal(' a ', getline(1)) |
| 225 | close! |
| 226 | let &cpo = save_cpo |
| 227 | endfunc |
| 228 | |
| 229 | " Test for the 'I' flag in 'cpo' (deleting autoindent when using arrow keys) |
| 230 | func Test_cpo_I() |
| 231 | let save_cpo = &cpo |
| 232 | new |
| 233 | setlocal autoindent |
| 234 | set cpo+=I |
| 235 | exe "normal i one\<CR>\<Up>" |
| 236 | call assert_equal(' ', getline(2)) |
| 237 | set cpo-=I |
| 238 | %d |
| 239 | exe "normal i one\<CR>\<Up>" |
| 240 | call assert_equal('', getline(2)) |
| 241 | close! |
| 242 | let &cpo = save_cpo |
| 243 | endfunc |
| 244 | |
| 245 | " Test for the 'J' flag in 'cpo' (two spaces after a sentence) |
| 246 | func Test_cpo_J() |
| 247 | let save_cpo = &cpo |
| 248 | new |
| 249 | set cpo-=J |
| 250 | call setline(1, 'one. two! three? four."'' five.)]') |
| 251 | normal 0 |
| 252 | for colnr in [6, 12, 19, 28, 34] |
| 253 | normal ) |
| 254 | call assert_equal(colnr, col('.')) |
| 255 | endfor |
| 256 | for colnr in [28, 19, 12, 6, 1] |
| 257 | normal ( |
| 258 | call assert_equal(colnr, col('.')) |
| 259 | endfor |
| 260 | set cpo+=J |
| 261 | normal 0 |
| 262 | for colnr in [12, 28, 34] |
| 263 | normal ) |
| 264 | call assert_equal(colnr, col('.')) |
| 265 | endfor |
| 266 | for colnr in [28, 12, 1] |
| 267 | normal ( |
| 268 | call assert_equal(colnr, col('.')) |
| 269 | endfor |
| 270 | close! |
| 271 | let &cpo = save_cpo |
| 272 | endfunc |
| 273 | |
| 274 | " TODO: Add a test for 'k' in 'cpo' |
| 275 | |
| 276 | " TODO: Add a test for 'K' in 'cpo' |
| 277 | |
| 278 | " Test for the 'l' flag in 'cpo' (backslash in a [] range) |
| 279 | func Test_cpo_l() |
| 280 | let save_cpo = &cpo |
| 281 | new |
| 282 | call setline(1, ['', "a\tc" .. '\t']) |
| 283 | set cpo-=l |
| 284 | exe 'normal gg/[\t]' .. "\<CR>" |
| 285 | call assert_equal([2, 8], [col('.'), virtcol('.')]) |
| 286 | set cpo+=l |
| 287 | exe 'normal gg/[\t]' .. "\<CR>" |
| 288 | call assert_equal([4, 10], [col('.'), virtcol('.')]) |
| 289 | close! |
| 290 | let &cpo = save_cpo |
| 291 | endfunc |
| 292 | |
| 293 | " Test for inserting tab in virtual replace mode ('L' flag in 'cpoptions') |
| 294 | func Test_cpo_L() |
| 295 | let save_cpo = &cpo |
| 296 | new |
| 297 | set cpo-=L |
| 298 | call setline(1, 'abcdefghijklmnopqr') |
| 299 | exe "normal 0gR\<Tab>" |
| 300 | call assert_equal("\<Tab>ijklmnopqr", getline(1)) |
| 301 | set cpo+=L |
| 302 | set list |
| 303 | call setline(1, 'abcdefghijklmnopqr') |
| 304 | exe "normal 0gR\<Tab>" |
| 305 | call assert_equal("\<Tab>cdefghijklmnopqr", getline(1)) |
| 306 | set nolist |
| 307 | call setline(1, 'abcdefghijklmnopqr') |
| 308 | exe "normal 0gR\<Tab>" |
| 309 | call assert_equal("\<Tab>ijklmnopqr", getline(1)) |
| 310 | close! |
| 311 | let &cpo = save_cpo |
| 312 | endfunc |
| 313 | |
| 314 | " TODO: This test doesn't work. |
| 315 | |
| 316 | " Test for the 'M' flag in 'cpo' (% with escape parenthesis) |
| 317 | func Test_cpo_M() |
| 318 | let save_cpo = &cpo |
| 319 | new |
| 320 | call setline(1, ['( \( )', '\( ( \)']) |
| 321 | |
| 322 | set cpo-=M |
| 323 | call cursor(1, 1) |
| 324 | normal % |
| 325 | call assert_equal(6, col('.')) |
| 326 | call cursor(1, 4) |
| 327 | call assert_beeps('normal %') |
| 328 | call cursor(2, 2) |
| 329 | normal % |
| 330 | call assert_equal(7, col('.')) |
| 331 | call cursor(2, 4) |
| 332 | call assert_beeps('normal %') |
| 333 | |
| 334 | set cpo+=M |
| 335 | call cursor(1, 4) |
| 336 | normal % |
| 337 | call assert_equal(6, col('.')) |
| 338 | call cursor(1, 1) |
| 339 | call assert_beeps('normal %') |
| 340 | call cursor(2, 4) |
| 341 | normal % |
| 342 | call assert_equal(7, col('.')) |
| 343 | call cursor(2, 1) |
| 344 | call assert_beeps('normal %') |
| 345 | |
| 346 | close! |
| 347 | let &cpo = save_cpo |
| 348 | endfunc |
| 349 | |
| 350 | " Test for the 'n' flag in 'cpo' (using number column for wrapped lines) |
| 351 | func Test_cpo_n() |
| 352 | let save_cpo = &cpo |
| 353 | new |
| 354 | call setline(1, repeat('a', &columns)) |
| 355 | setlocal number |
| 356 | set cpo-=n |
| 357 | redraw! |
| 358 | call assert_equal(' aaaa', Screenline(2)) |
| 359 | set cpo+=n |
| 360 | redraw! |
| 361 | call assert_equal('aaaa', Screenline(2)) |
| 362 | close! |
| 363 | let &cpo = save_cpo |
| 364 | endfunc |
| 365 | |
| 366 | " Test for the 'o' flag in 'cpo' (line offset to search command) |
| 367 | func Test_cpo_o() |
| 368 | let save_cpo = &cpo |
| 369 | new |
| 370 | call setline(1, ['', 'one', 'two', 'three', 'one', 'two', 'three']) |
| 371 | set cpo-=o |
| 372 | exe "normal /one/+2\<CR>" |
| 373 | normal n |
| 374 | call assert_equal(7, line('.')) |
| 375 | set cpo+=o |
| 376 | exe "normal /one/+2\<CR>" |
| 377 | normal n |
| 378 | call assert_equal(5, line('.')) |
| 379 | close! |
| 380 | let &cpo = save_cpo |
| 381 | endfunc |
| 382 | |
| 383 | " Test for the 'O' flag in 'cpo' (overwriting an existing file) |
| 384 | func Test_cpo_O() |
| 385 | let save_cpo = &cpo |
| 386 | new Xfile |
| 387 | call setline(1, 'one') |
| 388 | call writefile(['two'], 'Xfile') |
| 389 | set cpo-=O |
| 390 | call assert_fails('write', 'E13:') |
| 391 | set cpo+=O |
| 392 | write |
| 393 | call assert_equal(['one'], readfile('Xfile')) |
| 394 | close! |
| 395 | call delete('Xfile') |
| 396 | let &cpo = save_cpo |
| 397 | endfunc |
| 398 | |
| 399 | " Test for the 'P' flag in 'cpo' (appending to a file sets the current file |
| 400 | " name) |
| 401 | func Test_cpo_P() |
| 402 | let save_cpo = &cpo |
| 403 | call writefile([], 'Xfile') |
| 404 | new |
| 405 | call setline(1, 'one') |
| 406 | set cpo+=F |
| 407 | set cpo-=P |
| 408 | write >> Xfile |
| 409 | call assert_equal('', @%) |
| 410 | set cpo+=P |
| 411 | write >> Xfile |
| 412 | call assert_equal('Xfile', @%) |
| 413 | close! |
| 414 | call delete('Xfile') |
| 415 | let &cpo = save_cpo |
| 416 | endfunc |
| 417 | |
| 418 | " Test for the 'q' flag in 'cpo' (joining multiple lines) |
| 419 | func Test_cpo_q() |
| 420 | let save_cpo = &cpo |
| 421 | new |
| 422 | call setline(1, ['one', 'two', 'three', 'four', 'five']) |
| 423 | set cpo-=q |
| 424 | normal gg4J |
| 425 | call assert_equal(14, col('.')) |
| 426 | %d |
| 427 | call setline(1, ['one', 'two', 'three', 'four', 'five']) |
| 428 | set cpo+=q |
| 429 | normal gg4J |
| 430 | call assert_equal(4, col('.')) |
| 431 | close! |
| 432 | let &cpo = save_cpo |
| 433 | endfunc |
| 434 | |
| 435 | " Test for the 'r' flag in 'cpo' (redo command with a search motion) |
| 436 | func Test_cpo_r() |
| 437 | let save_cpo = &cpo |
| 438 | new |
| 439 | call setline(1, repeat(['one two three four'], 2)) |
| 440 | set cpo-=r |
| 441 | exe "normal ggc/two\<CR>abc " |
| 442 | let @/ = 'three' |
| 443 | normal 2G. |
| 444 | call assert_equal('abc two three four', getline(2)) |
| 445 | %d |
| 446 | call setline(1, repeat(['one two three four'], 2)) |
| 447 | set cpo+=r |
| 448 | exe "normal ggc/two\<CR>abc " |
| 449 | let @/ = 'three' |
| 450 | normal 2G. |
| 451 | call assert_equal('abc three four', getline(2)) |
| 452 | close! |
| 453 | let &cpo = save_cpo |
| 454 | endfunc |
| 455 | |
| 456 | " Test for the 'R' flag in 'cpo' (clear marks after a filter command) |
| 457 | func Test_cpo_R() |
| 458 | CheckUnix |
| 459 | let save_cpo = &cpo |
| 460 | new |
| 461 | call setline(1, ['three', 'one', 'two']) |
| 462 | set cpo-=R |
| 463 | 3mark r |
| 464 | %!sort |
| 465 | call assert_equal(3, line("'r")) |
| 466 | %d |
| 467 | call setline(1, ['three', 'one', 'two']) |
| 468 | set cpo+=R |
| 469 | 3mark r |
| 470 | %!sort |
| 471 | call assert_equal(0, line("'r")) |
| 472 | close! |
| 473 | let &cpo = save_cpo |
| 474 | endfunc |
| 475 | |
| 476 | " Test for the 'S' flag in 'cpo' (copying buffer options) |
| 477 | func Test_cpo_S() |
| 478 | let save_cpo = &cpo |
| 479 | new Xfile1 |
| 480 | set noautoindent |
| 481 | new Xfile2 |
| 482 | set cpo-=S |
| 483 | set autoindent |
| 484 | wincmd p |
| 485 | call assert_equal(0, &autoindent) |
| 486 | wincmd p |
| 487 | call assert_equal(1, &autoindent) |
| 488 | set cpo+=S |
| 489 | wincmd p |
| 490 | call assert_equal(1, &autoindent) |
| 491 | set noautoindent |
| 492 | wincmd p |
| 493 | call assert_equal(0, &autoindent) |
| 494 | wincmd t |
| 495 | close! |
| 496 | close! |
| 497 | let &cpo = save_cpo |
| 498 | endfunc |
| 499 | |
| 500 | " Test for the 'u' flag in 'cpo' (Vi-compatible undo) |
| 501 | func Test_cpo_u() |
| 502 | let save_cpo = &cpo |
| 503 | new |
| 504 | set cpo-=u |
| 505 | exe "normal iabc\<C-G>udef\<C-G>ughi" |
| 506 | normal uu |
| 507 | call assert_equal('abc', getline(1)) |
| 508 | %d |
| 509 | set cpo+=u |
| 510 | exe "normal iabc\<C-G>udef\<C-G>ughi" |
| 511 | normal uu |
| 512 | call assert_equal('abcdefghi', getline(1)) |
| 513 | close! |
| 514 | let &cpo = save_cpo |
| 515 | endfunc |
| 516 | |
| 517 | " Test for the 'x' flag in 'cpo' (Esc on command-line executes command) |
| 518 | func Test_cpo_x() |
| 519 | let save_cpo = &cpo |
| 520 | set cpo-=x |
| 521 | let i = 1 |
| 522 | call feedkeys(":let i=10\<Esc>", 'xt') |
| 523 | call assert_equal(1, i) |
| 524 | set cpo+=x |
| 525 | call feedkeys(":let i=10\<Esc>", 'xt') |
| 526 | call assert_equal(10, i) |
| 527 | let &cpo = save_cpo |
| 528 | endfunc |
| 529 | |
| 530 | " Test for the 'X' flag in 'cpo' ('R' with a count) |
| 531 | func Test_cpo_X() |
| 532 | let save_cpo = &cpo |
| 533 | new |
| 534 | call setline(1, 'aaaaaa') |
| 535 | set cpo-=X |
| 536 | normal gg4Rx |
| 537 | call assert_equal('xxxxaa', getline(1)) |
| 538 | normal ggRy |
| 539 | normal 4. |
| 540 | call assert_equal('yyyyaa', getline(1)) |
| 541 | call setline(1, 'aaaaaa') |
| 542 | set cpo+=X |
| 543 | normal gg4Rx |
| 544 | call assert_equal('xxxxaaaaa', getline(1)) |
| 545 | normal ggRy |
| 546 | normal 4. |
| 547 | call assert_equal('yyyyxxxaaaaa', getline(1)) |
| 548 | close! |
| 549 | let &cpo = save_cpo |
| 550 | endfunc |
| 551 | |
| 552 | " Test for the 'y' flag in 'cpo' (repeating a yank command) |
| 553 | func Test_cpo_y() |
| 554 | let save_cpo = &cpo |
| 555 | new |
| 556 | call setline(1, ['one', 'two']) |
| 557 | set cpo-=y |
| 558 | normal ggyy |
| 559 | normal 2G. |
| 560 | call assert_equal("one\n", @") |
| 561 | %d |
| 562 | call setline(1, ['one', 'two']) |
| 563 | set cpo+=y |
| 564 | normal ggyy |
| 565 | normal 2G. |
| 566 | call assert_equal("two\n", @") |
| 567 | close! |
| 568 | let &cpo = save_cpo |
| 569 | endfunc |
| 570 | |
| 571 | " Test for the 'Z' flag in 'cpo' (write! resets 'readonly') |
| 572 | func Test_cpo_Z() |
| 573 | let save_cpo = &cpo |
| 574 | call writefile([], 'Xfile') |
| 575 | new Xfile |
| 576 | setlocal readonly |
| 577 | set cpo-=Z |
| 578 | write! |
| 579 | call assert_equal(0, &readonly) |
| 580 | set cpo+=Z |
| 581 | setlocal readonly |
| 582 | write! |
| 583 | call assert_equal(1, &readonly) |
| 584 | close! |
| 585 | call delete('Xfile') |
| 586 | let &cpo = save_cpo |
| 587 | endfunc |
| 588 | |
| 589 | " Test for cursor movement with '-' in 'cpoptions' |
| 590 | func Test_cpo_minus() |
| 591 | new |
| 592 | call setline(1, ['foo', 'bar', 'baz']) |
| 593 | let save_cpo = &cpo |
| 594 | set cpo+=- |
| 595 | call assert_beeps('normal 10j') |
| 596 | call assert_equal(1, line('.')) |
| 597 | normal G |
| 598 | call assert_beeps('normal 10k') |
| 599 | call assert_equal(3, line('.')) |
| 600 | call assert_fails(10, 'E16:') |
| 601 | let &cpo = save_cpo |
| 602 | close! |
| 603 | endfunc |
| 604 | |
| 605 | " Test for displaying dollar when changing text ('$' flag in 'cpoptions') |
| 606 | func Test_cpo_dollar() |
| 607 | new |
| 608 | let g:Line = '' |
| 609 | func SaveFirstLine() |
| 610 | let g:Line = Screenline(1) |
| 611 | return '' |
| 612 | endfunc |
| 613 | inoremap <expr> <buffer> <F2> SaveFirstLine() |
| 614 | call test_override('redraw_flag', 1) |
| 615 | set cpo+=$ |
| 616 | call setline(1, 'one two three') |
| 617 | redraw! |
| 618 | exe "normal c2w\<F2>vim" |
| 619 | call assert_equal('one tw$ three', g:Line) |
| 620 | call assert_equal('vim three', getline(1)) |
| 621 | set cpo-=$ |
| 622 | call test_override('ALL', 0) |
| 623 | delfunc SaveFirstLine |
| 624 | %bw! |
| 625 | endfunc |
| 626 | |
| 627 | " vim: shiftwidth=2 sts=2 expandtab |