robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear =n . clear 7local command =n . command 8local expect =n . expect 9local feed =n . feed 10local sleep =vim . uv . sleep 11 12before_each ( clear ) 13 14describe ( 'edit' , function () 15-- oldtest: Test_autoindent_remove_indent() 16it ( 'autoindent removes indent when Insert mode is stopped' , function () 17command ( 'set autoindent' ) 18-- leaving insert mode in a new line with indent added by autoindent, should 19-- remove the indent. 20feed ( 'i<Tab>foo<CR><Esc>' ) 21-- Need to delay for sometime, otherwise the code in input.c will not be 22-- exercised. 23sleep ( 50 ) 24-- when a line is wrapped and the cursor is at the start of the second line, 25-- leaving insert mode, should move the cursor back to the first line. 26feed ( 'o' .. ( 'x' ): rep ( 20 ) .. '<Esc>' ) 27-- Need to delay for sometime, otherwise the code in input.c will not be 28-- exercised. 29sleep ( 50 ) 30expect ( '\tfoo\n\n' .. ( 'x' ): rep ( 20 )) 31end ) 32 33-- oldtest: Test_edit_insert_reg() 34it ( 'inserting a register using CTRL-R' , function () 35local screen =Screen . new ( 10 , 6 ) 36feed ( 'a<C-R>' ) 37screen : expect ( [[ 38{18:^"} | 39{1:~ }|*4 40{5:-- INSERT --}| 41]] ) 42feed ( '=' ) 43screen : expect ( [[ 44{18:"} | 45{1:~ }|*4 46=^ | 47]] ) 48feed ( [['r'<CR><Esc>]] ) 49expect ( 'r' ) 50-- Test for inserting null and empty list 51feed ( 'a<C-R>=v:_null_list<CR><Esc>' ) 52feed ( 'a<C-R>=[]<CR><Esc>' ) 53expect ( 'r' ) 54end ) 55 56-- oldtest: Test_edit_ctrl_r_failed() 57it ( 'positioning cursor after CTRL-R expression failed' , function () 58local screen =Screen . new ( 60 , 6 ) 59 60feed ( 'i<C-R>' ) 61screen : expect ( [[ 62{18:^"} | 63{1:~ }|*4 64{5:-- INSERT --} | 65]] ) 66feed ( '=0z' ) 67screen : expect ( [[ 68{18:"} | 69{1:~ }|*4 70={26:0}{9:z}^ | 71]] ) 72-- trying to insert a blob produces an error 73feed ( '<CR>' ) 74screen : expect ( [[ 75{18:"} | 76{1:~ }| 77{3: }| 78={26:0}{9:z} | 79{9:E976: Using a Blob as a String} | 80{6:Press ENTER or type command to continue}^ | 81]] ) 82 83feed ( ':' ) 84screen : expect ( [[ 85:^ | 86{1:~ }|*4 87{5:-- INSERT --} | 88]] ) 89-- ending Insert mode should put the cursor back on the ':' 90feed ( '<Esc>' ) 91screen : expect ( [[ 92^: | 93{1:~ }|*4 94| 95]] ) 96end ) 97 98-- oldtest: Test_edit_CAR() 99it ( 'Enter inserts newline with pum at original text after adding leader' , function () 100local screen =Screen . new ( 10 , 6 ) 101command ( 'set cot=menu,menuone,noselect' ) 102feed ( 'Shello hero<CR>h<C-X><C-N>e' ) 103screen : expect ( [[ 104hello hero | 105he^ | 106{4:hello }| 107{4:hero }| 108{1:~ }| 109{5:--} | 110]] ) 111 112feed ( '<CR>' ) 113screen : expect ( [[ 114hello hero | 115he | 116^ | 117{1:~ }|*2 118{5:-- INSERT --}| 119]] ) 120end ) 121end )