Mercurial > vim
comparison src/testdir/test_viminfo.vim @ 24982:4cb423b9250d v8.2.3028
patch 8.2.3028: GUI mouse events not tested
Commit: https://github.com/vim/vim/commit/f1e7449d567c630601aa0cec6c663b791785a668
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Jun 21 18:44:26 2021 +0200
patch 8.2.3028: GUI mouse events not tested
Problem: GUI mouse events not tested.
Solution: Add test_gui_mouse_event(). Add mouse tests. Also add a few
viminfo tests. (Yegappan Lakshmanan, closes #8407)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 21 Jun 2021 18:45:04 +0200 |
parents | 21ec48d542a8 |
children | 485c7c4afeb7 |
comparison
equal
deleted
inserted
replaced
24981:f8566203119e | 24982:4cb423b9250d |
---|---|
61 let g:MY_GLOBAL_TRUE = test_true | 61 let g:MY_GLOBAL_TRUE = test_true |
62 let test_null = v:null | 62 let test_null = v:null |
63 let g:MY_GLOBAL_NULL = test_null | 63 let g:MY_GLOBAL_NULL = test_null |
64 let test_none = v:none | 64 let test_none = v:none |
65 let g:MY_GLOBAL_NONE = test_none | 65 let g:MY_GLOBAL_NONE = test_none |
66 let g:MY_GLOBAL_FUNCREF = function('min') | |
66 | 67 |
67 set viminfo='100,<50,s10,h,!,nviminfo | 68 set viminfo='100,<50,s10,h,!,nviminfo |
68 wv! Xviminfo | 69 wv! Xviminfo |
69 | 70 |
70 unlet g:MY_GLOBAL_STRING | 71 unlet g:MY_GLOBAL_STRING |
75 unlet g:MY_GLOBAL_BLOB | 76 unlet g:MY_GLOBAL_BLOB |
76 unlet g:MY_GLOBAL_FALSE | 77 unlet g:MY_GLOBAL_FALSE |
77 unlet g:MY_GLOBAL_TRUE | 78 unlet g:MY_GLOBAL_TRUE |
78 unlet g:MY_GLOBAL_NULL | 79 unlet g:MY_GLOBAL_NULL |
79 unlet g:MY_GLOBAL_NONE | 80 unlet g:MY_GLOBAL_NONE |
81 unlet g:MY_GLOBAL_FUNCREF | |
80 | 82 |
81 rv! Xviminfo | 83 rv! Xviminfo |
82 call assert_equal("Vim Editor", g:MY_GLOBAL_STRING) | 84 call assert_equal("Vim Editor", g:MY_GLOBAL_STRING) |
83 call assert_equal(345, g:MY_GLOBAL_NUM) | 85 call assert_equal(345, g:MY_GLOBAL_NUM) |
84 call assert_equal(3.14, g:MY_GLOBAL_FLOAT) | 86 call assert_equal(3.14, g:MY_GLOBAL_FLOAT) |
87 call assert_equal(test_blob, g:MY_GLOBAL_BLOB) | 89 call assert_equal(test_blob, g:MY_GLOBAL_BLOB) |
88 call assert_equal(test_false, g:MY_GLOBAL_FALSE) | 90 call assert_equal(test_false, g:MY_GLOBAL_FALSE) |
89 call assert_equal(test_true, g:MY_GLOBAL_TRUE) | 91 call assert_equal(test_true, g:MY_GLOBAL_TRUE) |
90 call assert_equal(test_null, g:MY_GLOBAL_NULL) | 92 call assert_equal(test_null, g:MY_GLOBAL_NULL) |
91 call assert_equal(test_none, g:MY_GLOBAL_NONE) | 93 call assert_equal(test_none, g:MY_GLOBAL_NONE) |
94 call assert_false(exists("g:MY_GLOBAL_FUNCREF")) | |
92 | 95 |
93 " When reading global variables from viminfo, if a variable cannot be | 96 " When reading global variables from viminfo, if a variable cannot be |
94 " modified, then the value should not be changed. | 97 " modified, then the value should not be changed. |
95 unlet g:MY_GLOBAL_STRING | 98 unlet g:MY_GLOBAL_STRING |
96 unlet g:MY_GLOBAL_NUM | 99 unlet g:MY_GLOBAL_NUM |
228 rviminfo Xviminfo | 231 rviminfo Xviminfo |
229 call assert_equal("echo " . long1400, histget(':', -1)) | 232 call assert_equal("echo " . long1400, histget(':', -1)) |
230 call assert_equal("echo " . long800, histget(':', -2)) | 233 call assert_equal("echo " . long800, histget(':', -2)) |
231 call assert_equal("echo 'one'", histget(':', -3)) | 234 call assert_equal("echo 'one'", histget(':', -3)) |
232 | 235 |
233 call delete('Xviminfo') | 236 " If the value for the '/' or ':' or '@' field in 'viminfo' is zero, then |
237 " the corresponding history entries are not saved. | |
238 set viminfo='100,/0,:0,@0,<50,s10,h,!,nviminfo | |
239 call histdel('/') | |
240 call histdel(':') | |
241 call histdel('@') | |
242 call histadd('/', 'foo') | |
243 call histadd(':', 'bar') | |
244 call histadd('@', 'baz') | |
245 wviminfo! Xviminfo | |
246 call histdel('/') | |
247 call histdel(':') | |
248 call histdel('@') | |
249 rviminfo! Xviminfo | |
250 call assert_equal('', histget('/')) | |
251 call assert_equal('', histget(':')) | |
252 call assert_equal('', histget('@')) | |
253 | |
254 call delete('Xviminfo') | |
255 set viminfo&vim | |
234 endfunc | 256 endfunc |
235 | 257 |
236 func Test_cmdline_history_order() | 258 func Test_cmdline_history_order() |
237 call histdel(':') | 259 call histdel(':') |
238 call test_settime(11) | 260 call test_settime(11) |
344 call assert_equal(s, getreg('"'), 'wrong register at length: ' . len) | 366 call assert_equal(s, getreg('"'), 'wrong register at length: ' . len) |
345 | 367 |
346 let len += 1 | 368 let len += 1 |
347 endwhile | 369 endwhile |
348 | 370 |
349 call delete('Xviminfo') | 371 " If the maximum number of lines saved for a register ('<' in 'viminfo') is |
372 " zero, then register values should not be saved. | |
373 let @a = 'abc' | |
374 set viminfo='100,<0,s10,h,!,nviminfo | |
375 wviminfo Xviminfo | |
376 let @a = 'xyz' | |
377 rviminfo! Xviminfo | |
378 call assert_equal('xyz', @a) | |
379 " repeat the test with '"' instead of '<' | |
380 let @b = 'def' | |
381 set viminfo='100,\"0,s10,h,!,nviminfo | |
382 wviminfo Xviminfo | |
383 let @b = 'rst' | |
384 rviminfo! Xviminfo | |
385 call assert_equal('rst', @b) | |
386 | |
387 " If the maximum size of an item ('s' in 'viminfo') is zero, then register | |
388 " values should not be saved. | |
389 let @c = '123' | |
390 set viminfo='100,<20,s0,h,!,nviminfo | |
391 wviminfo Xviminfo | |
392 let @c = '456' | |
393 rviminfo! Xviminfo | |
394 call assert_equal('456', @c) | |
395 | |
396 call delete('Xviminfo') | |
397 set viminfo&vim | |
350 endfunc | 398 endfunc |
351 | 399 |
352 func Test_viminfo_marks() | 400 func Test_viminfo_marks() |
353 sp bufa | 401 sp bufa |
354 let bufa = bufnr('%') | 402 let bufa = bufnr('%') |
539 rviminfo Xviminfo | 587 rviminfo Xviminfo |
540 | 588 |
541 call delete('Xviminfo') | 589 call delete('Xviminfo') |
542 endfunc | 590 endfunc |
543 | 591 |
544 func Test_viminfo_bad_register_syntax() | 592 func Test_viminfo_bad_syntax2() |
545 let lines = [] | 593 let lines = [] |
546 call add(lines, '|1,4') | 594 call add(lines, '|1,4') |
547 call add(lines, '|3') " invalid number of fields for a register type | 595 |
548 call add(lines, '|3,1,1,1,1,,1,"x"') " invalid value for the width field | 596 " bad viminfo syntax for history barline |
597 call add(lines, '|2') " invalid number of fields in a history barline | |
598 call add(lines, '|2,9,1,1,"x"') " invalid value for the history type | |
599 call add(lines, '|2,0,,1,"x"') " no timestamp | |
600 call add(lines, '|2,0,1,1,10') " non-string text | |
601 | |
602 " bad viminfo syntax for register barline | |
603 call add(lines, '|3') " invalid number of fields in a register barline | |
604 call add(lines, '|3,1,1,1,1,,1,"x"') " missing width field | |
549 call add(lines, '|3,0,80,1,1,1,1,"x"') " invalid register number | 605 call add(lines, '|3,0,80,1,1,1,1,"x"') " invalid register number |
550 call add(lines, '|3,0,10,5,1,1,1,"x"') " invalid register type | 606 call add(lines, '|3,0,10,5,1,1,1,"x"') " invalid register type |
551 call add(lines, '|3,0,10,1,20,1,1,"x"') " invalid line count | 607 call add(lines, '|3,0,10,1,20,1,1,"x"') " invalid line count |
552 call add(lines, '|3,0,10,1,0,1,1') " zero line count | 608 call add(lines, '|3,0,10,1,0,1,1') " zero line count |
609 | |
610 " bad viminfo syntax for mark barline | |
611 call add(lines, '|4') " invalid number of fields in a mark barline | |
612 call add(lines, '|4,1,1,1,1,1') " invalid value for file name | |
613 call add(lines, '|4,20,1,1,1,"x"') " invalid value for file name | |
614 call add(lines, '|4,49,0,1,1,"x"') " invalid value for line number | |
615 | |
553 call writefile(lines, 'Xviminfo') | 616 call writefile(lines, 'Xviminfo') |
554 rviminfo Xviminfo | 617 rviminfo Xviminfo |
555 call delete('Xviminfo') | 618 call delete('Xviminfo') |
556 endfunc | 619 endfunc |
557 | 620 |
899 call delete('Xviminfo') | 962 call delete('Xviminfo') |
900 | 963 |
901 " Try to write the viminfo to a directory | 964 " Try to write the viminfo to a directory |
902 call mkdir('Xdir') | 965 call mkdir('Xdir') |
903 call assert_fails('wviminfo Xdir', 'E137:') | 966 call assert_fails('wviminfo Xdir', 'E137:') |
967 call assert_fails('rviminfo Xdir', 'E195:') | |
904 call delete('Xdir', 'rf') | 968 call delete('Xdir', 'rf') |
905 endfunc | 969 endfunc |
906 | 970 |
907 " Test for writing to an existing viminfo file merges the file marks | 971 " Test for writing to an existing viminfo file merges the file marks |
908 func XTest_viminfo_marks_merge() | 972 func XTest_viminfo_marks_merge() |