robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for 'fixeol' 2 3local n =require ( 'test.functional.testnvim' )() 4local t =require ( 'test.testutil' ) 5 6local describe , it , setup , teardown =t . describe , t . it , t . setup , t . teardown 7local feed =n . feed 8local clear , feed_command , expect =n . clear , n . feed_command , n . expect 9 10describe ( 'fixeol' , function () 11local function rmtestfiles () 12os . remove ( 'test.out' ) 13os . remove ( 'XXEol' ) 14os . remove ( 'XXNoEol' ) 15os . remove ( 'XXTestEol' ) 16os . remove ( 'XXTestNoEol' ) 17end 18setup ( function () 19clear () 20rmtestfiles () 21end ) 22teardown ( function () 23rmtestfiles () 24end ) 25 26it ( 'is working' , function () 27-- First write two test files – with and without trailing EOL. 28feed_command ( 'enew!' ) 29feed ( 'awith eol<esc>:w! XXEol<cr>' ) 30feed_command ( 'enew!' ) 31feed_command ( 'set noeol nofixeol' ) 32feed ( 'awithout eol<esc>:w! XXNoEol<cr>' ) 33feed_command ( 'set eol fixeol' ) 34feed_command ( 'bwipe XXEol XXNoEol' ) 35 36-- Try editing files with 'fixeol' disabled. 37feed_command ( 'e! XXEol' ) 38feed ( 'ostays eol<esc>:set nofixeol<cr>' ) 39feed_command ( 'w! XXTestEol' ) 40feed_command ( 'e! XXNoEol' ) 41feed ( 'ostays without<esc>:set nofixeol<cr>' ) 42feed_command ( 'w! XXTestNoEol' ) 43feed_command ( 'bwipe! XXEol XXNoEol XXTestEol XXTestNoEol' ) 44feed_command ( 'set fixeol' ) 45 46-- Append "END" to each file so that we can see what the last written char was. 47feed ( 'ggdGaEND<esc>:w >>XXEol<cr>' ) 48feed_command ( 'w >>XXNoEol' ) 49feed_command ( 'w >>XXTestEol' ) 50feed_command ( 'w >>XXTestNoEol' ) 51 52-- Concatenate the results. 53feed_command ( 'e! test.out' ) 54feed ( 'a0<esc>:$r XXEol<cr>' ) 55feed_command ( '$r XXNoEol' ) 56feed ( 'Go1<esc>:$r XXTestEol<cr>' ) 57feed_command ( '$r XXTestNoEol' ) 58feed_command ( 'w' ) 59 60-- Assert buffer contents. 61expect ( [=[ 620 63with eol 64END 65without eolEND 661 67with eol 68stays eol 69END 70without eol 71stays withoutEND]=] ) 72end ) 73end )