Bram Moolenaar | 15993ce | 2017-10-26 20:21:44 +0200 | [diff] [blame^] | 1 | |
| 2 | " Test for insert expansion |
| 3 | func Test_ins_complete() |
| 4 | set ff=unix |
| 5 | call writefile(["test11\t36Gepeto\t/Tag/", |
| 6 | \ "asd\ttest11file\t36G", |
| 7 | \ "Makefile\tto\trun"], 'Xtestfile') |
| 8 | call writefile(['', 'start of testfile', |
| 9 | \ 'ru', |
| 10 | \ 'run1', |
| 11 | \ 'run2', |
| 12 | \ 'STARTTEST', |
| 13 | \ 'ENDTEST', |
| 14 | \ 'end of testfile'], 'Xtestdata') |
| 15 | set ff& |
| 16 | |
| 17 | enew! |
| 18 | edit Xtestdata |
| 19 | new |
| 20 | call append(0, ['#include "Xtestfile"', '']) |
| 21 | call cursor(2, 1) |
| 22 | |
| 23 | set cot= |
| 24 | set cpt=.,w |
| 25 | " add-expands (word from next line) from other window |
| 26 | exe "normal iru\<C-N>\<C-N>\<C-X>\<C-N>\<Esc>\<C-A>" |
| 27 | call assert_equal('run1 run3', getline('.')) |
| 28 | " add-expands (current buffer first) |
| 29 | exe "normal o\<C-P>\<C-X>\<C-N>" |
| 30 | call assert_equal('run3 run3', getline('.')) |
| 31 | " Local expansion, ends in an empty line (unless it becomes a global |
| 32 | " expansion) |
| 33 | exe "normal o\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>" |
| 34 | call assert_equal('', getline('.')) |
| 35 | " starts Local and switches to global add-expansion |
| 36 | exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>" |
| 37 | call assert_equal('run1 run2', getline('.')) |
| 38 | |
| 39 | set cpt=.,w,i |
| 40 | " i-add-expands and switches to local |
| 41 | exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>" |
| 42 | call assert_equal("Makefile\tto\trun3", getline('.')) |
| 43 | " add-expands lines (it would end in an empty line if it didn't ignored |
| 44 | " itself) |
| 45 | exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>" |
| 46 | call assert_equal("Makefile\tto\trun3", getline('.')) |
| 47 | call assert_equal("Makefile\tto\trun3", getline(line('.') - 1)) |
| 48 | |
| 49 | set cpt=kXtestfile |
| 50 | " checks k-expansion, and file expansion (use Xtest11 instead of test11, |
| 51 | " because TEST11.OUT may match first on DOS) |
| 52 | write Xtest11.one |
| 53 | write Xtest11.two |
| 54 | exe "normal o\<C-N>\<Esc>IX\<Esc>A\<C-X>\<C-F>\<C-N>" |
| 55 | call assert_equal('Xtest11.two', getline('.')) |
| 56 | |
| 57 | " use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X |
| 58 | " CTRL-F again to verify this doesn't cause trouble. |
| 59 | exe "normal oXt\<C-X>\<C-F>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<C-X>\<C-F>" |
| 60 | call assert_equal('Xtest11.one', getline('.')) |
| 61 | normal ddk |
| 62 | |
| 63 | set cpt=w |
| 64 | " checks make_cyclic in other window |
| 65 | exe "normal oST\<C-N>\<C-P>\<C-P>\<C-P>\<C-P>" |
| 66 | call assert_equal('STARTTEST', getline('.')) |
| 67 | |
| 68 | set cpt=u nohid |
| 69 | " checks unloaded buffer expansion |
| 70 | only |
| 71 | exe "normal oEN\<C-N>" |
| 72 | call assert_equal('ENDTEST', getline('.')) |
| 73 | " checks adding mode abortion |
| 74 | exe "normal ounl\<C-N>\<C-X>\<C-X>\<C-P>" |
| 75 | call assert_equal('unless', getline('.')) |
| 76 | |
| 77 | set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch |
| 78 | " tag expansion, define add-expansion interrupted |
| 79 | exe "normal o\<C-X>\<C-]>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>" |
| 80 | call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.')) |
| 81 | " t-expansion |
| 82 | exe "normal oa\<C-N>\<Esc>" |
| 83 | call assert_equal('asd', getline('.')) |
| 84 | |
| 85 | %bw! |
| 86 | call delete('Xtestfile') |
| 87 | call delete('Xtest11.one') |
| 88 | call delete('Xtest11.two') |
| 89 | call delete('Xtestdata') |
| 90 | set cpt& cot& def& tags& tagbsearch& hidden& |
| 91 | endfunc |