robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for undo file. 2-- Since this script is sourced we need to explicitly break changes up in 3-- undo-able pieces. Do that by setting 'undolevels'. 4 5local n =require ( 'test.functional.testnvim' )() 6local t =require ( 'test.testutil' ) 7 8local describe , it , setup , teardown =t . describe , t . it , t . setup , t . teardown 9local feed , insert =n . feed , n . insert 10local clear , feed_command , expect =n . clear , n . feed_command , n . expect 11 12describe ( '72' , function () 13setup ( clear ) 14 15it ( 'is working' , function () 16insert ( [[ 171111 ----- 182222 ----- 19 20123456789]] ) 21 22-- Test 'undofile': first a simple one-line change. 23feed_command ( 'set visualbell' ) 24feed_command ( 'set ul=100 undofile undodir=. nomore' ) 25feed_command ( 'e! Xtestfile' ) 26feed ( 'ggdGithis is one line<esc>:set ul=100<cr>' ) 27feed_command ( 's/one/ONE/' ) 28feed_command ( 'set ul=100' ) 29feed_command ( 'w' ) 30feed_command ( 'bwipe!' ) 31feed_command ( 'e Xtestfile' ) 32feed ( 'u:.w! test.out<cr>' ) 33 34-- Test 'undofile', change in original file fails check. 35feed_command ( 'set noundofile' ) 36feed_command ( 'e! Xtestfile' ) 37feed_command ( 's/line/Line/' ) 38feed_command ( 'w' ) 39feed_command ( 'set undofile' ) 40feed_command ( 'bwipe!' ) 41feed_command ( 'e Xtestfile' ) 42---- TODO: this beeps. 43feed ( 'u:.w >>test.out<cr>' ) 44 45-- Test 'undofile', add 10 lines, delete 6 lines, undo 3. 46feed_command ( 'set undofile' ) 47feed ( 'ggdGione<cr>' ) 48feed ( 'two<cr>' ) 49feed ( 'three<cr>' ) 50feed ( 'four<cr>' ) 51feed ( 'five<cr>' ) 52feed ( 'six<cr>' ) 53feed ( 'seven<cr>' ) 54feed ( 'eight<cr>' ) 55feed ( 'nine<cr>' ) 56feed ( 'ten<esc>:set ul=100<cr>' ) 57feed ( '3Gdd:set ul=100<cr>' ) 58feed ( 'dd:set ul=100<cr>' ) 59feed ( 'dd:set ul=100<cr>' ) 60feed ( 'dd:set ul=100<cr>' ) 61feed ( 'dd:set ul=100<cr>' ) 62feed ( 'dd:set ul=100<cr>' ) 63feed_command ( 'w' ) 64feed_command ( 'bwipe!' ) 65feed_command ( 'e Xtestfile' ) 66feed ( 'uuu:w >>test.out<cr>' ) 67 68-- Test that reading the undofiles when setting undofile works. 69feed_command ( 'set noundofile ul=0' ) 70feed ( 'i<cr>' ) 71feed ( '<esc>u:e! Xtestfile<cr>' ) 72feed_command ( 'set undofile ul=100' ) 73feed ( 'uuuuuu:w >>test.out<cr>' ) 74 75---- Open the output to see if it meets the expectations 76feed_command ( 'e! test.out' ) 77 78-- Assert buffer contents. 79expect ( [[ 80this is one line 81this is ONE Line 82one 83two 84six 85seven 86eight 87nine 88ten 89one 90two 91three 92four 93five 94six 95seven 96eight 97nine 98ten]] ) 99end ) 100 101teardown ( function () 102os . remove ( 'Xtestfile' ) 103os . remove ( 'test.out' ) 104os . remove ( '.Xtestfile.un~' ) 105end ) 106end )