robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for Unicode manipulations 2 3local t =require ( 'test.testutil' ) 4local n =require ( 'test.functional.testnvim' )() 5 6local describe , it , before_each =t . describe , t . it , t . before_each 7local clear , feed , insert =n . clear , n . feed , n . insert 8local command , expect =n . command , n . expect 9local eq , eval =t . eq , n . eval 10local source =n . source 11local poke_eventloop =n . poke_eventloop 12 13describe ( 'utf8' , function () 14before_each ( clear ) 15 16it ( 'is working' , function () 17insert ( 'start:' ) 18 19command ( 'new' ) 20command ( 'call setline(1, ["aaa", "あああ", "bbb"])' ) 21 22-- Visual block Insert adjusts for multi-byte char 23feed ( 'gg0l<C-V>jjIx<Esc>' ) 24poke_eventloop () 25 26command ( 'let r = getline(1, "$")' ) 27command ( 'bwipeout!' ) 28command ( '$put=r' ) 29command ( 'call garbagecollect(1)' ) 30 31expect ( [[ 32start: 33axaa 34xあああ 35bxbb]] ) 36end ) 37 38it ( 'strchars()' , function () 39eq ( 1 , eval ( 'strchars("a")' )) 40eq ( 1 , eval ( 'strchars("a", 0)' )) 41eq ( 1 , eval ( 'strchars("a", 1)' )) 42 43eq ( 3 , eval ( 'strchars("あいa")' )) 44eq ( 3 , eval ( 'strchars("あいa", 0)' )) 45eq ( 3 , eval ( 'strchars("あいa", 1)' )) 46 47eq ( 2 , eval ( 'strchars("A\\u20dd")' )) 48eq ( 2 , eval ( 'strchars("A\\u20dd", 0)' )) 49eq ( 1 , eval ( 'strchars("A\\u20dd", 1)' )) 50 51eq ( 3 , eval ( 'strchars("A\\u20dd\\u20dd")' )) 52eq ( 3 , eval ( 'strchars("A\\u20dd\\u20dd", 0)' )) 53eq ( 1 , eval ( 'strchars("A\\u20dd\\u20dd", 1)' )) 54 55eq ( 1 , eval ( 'strchars("\\u20dd")' )) 56eq ( 1 , eval ( 'strchars("\\u20dd", 0)' )) 57eq ( 1 , eval ( 'strchars("\\u20dd", 1)' )) 58end ) 59 60-- luacheck: ignore 613 (Trailing whitespace in a string) 61it ( 'customlist completion' , function () 62source ( [[ 63function! CustomComplete1(lead, line, pos) 64return ['あ', 'い'] 65endfunction 66command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo]] ) 67feed ( ":Test1 <C-L>'<C-B>$put='<CR>" ) 68 69source ( [[ 70function! CustomComplete2(lead, line, pos) 71return ['あたし', 'あたま', 'あたりめ'] 72endfunction 73command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo]] ) 74feed ( ":Test2 <C-L>'<C-B>$put='<CR>" ) 75 76source ( [[ 77function! CustomComplete3(lead, line, pos) 78return ['Nこ', 'Nん', 'Nぶ'] 79endfunction 80command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo]] ) 81feed ( ":Test3 <C-L>'<C-B>$put='<CR>" ) 82 83expect ( [[ 84 85Test1 86Test2 あた 87Test3 N]] ) 88end ) 89end )