robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for storing global variables in the .shada file 2 3local t =require ( 'test.testutil' ) 4local n =require ( 'test.functional.testnvim' )() 5 6local describe , it , setup , teardown =t . describe , t . it , t . setup , t . teardown 7local clear , command , eq , neq , eval , poke_eventloop = 8n . clear , n . command , t . eq , t . neq , n . eval , n . poke_eventloop 9 10describe ( 'storing global variables in ShaDa files' , function () 11local tempname ='Xtest-functional-legacy-074' 12setup ( function () 13clear () 14os . remove ( tempname ) 15end ) 16 17it ( 'is working' , function () 18clear { args_rm ={ '-i' } , args ={ '-i' , 'Xviminfo' } } 19 20local test_dict ={ foo =1 , bar =0 , longvarible =1000 } 21local test_list ={ 221 , 232 , 243 , 254 , 265 , 276 , 287 , 298 , 309 , 3110 , 3211 , 3312 , 3413 , 3514 , 3615 , 3716 , 3817 , 3918 , 4019 , 4120 , 4221 , 4322 , 4423 , 4524 , 4625 , 4726 , 4827 , 4928 , 5029 , 5130 , 5231 , 5332 , 5433 , 5534 , 5635 , 5736 , 5837 , 5938 , 6039 , 6140 , 6241 , 6342 , 6443 , 6544 , 6645 , 6746 , 6847 , 6948 , 7049 , 7150 , 7251 , 7352 , 7453 , 7554 , 7655 , 7756 , 7857 , 7958 , 8059 , 8160 , 8261 , 8362 , 8463 , 8564 , 8665 , 8766 , 8867 , 8968 , 9069 , 9170 , 9271 , 9372 , 9473 , 9574 , 9675 , 9776 , 9877 , 9978 , 10079 , 10180 , 10281 , 10382 , 10483 , 10584 , 10685 , 10786 , 10887 , 10988 , 11089 , 11190 , 11291 , 11392 , 11493 , 11594 , 11695 , 11796 , 11897 , 11998 , 12099 , 121100 , 122} 123 124command ( 'set visualbell' ) 125command ( 'set shada+=!' ) 126command ( "let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}" ) 127-- Store a really long list. Initially this was testing line wrapping in 128-- viminfo, but shada files has no line wrapping, no matter how long the 129-- list is. 130command ( 'let MY_GLOBAL_LIST=range(1, 100)' ) 131 132eq ( test_dict , eval ( 'MY_GLOBAL_DICT' )) 133eq ( test_list , eval ( 'MY_GLOBAL_LIST' )) 134 135command ( 'wsh! ' .. tempname ) 136poke_eventloop () 137 138-- Assert that the shada file exists. 139neq ( nil , vim . uv . fs_stat ( tempname )) 140command ( 'unlet MY_GLOBAL_DICT' ) 141command ( 'unlet MY_GLOBAL_LIST' ) 142-- Assert that the variables where deleted. 143eq ( 0 , eval ( 'exists("MY_GLOBAL_DICT")' )) 144eq ( 0 , eval ( 'exists("MY_GLOBAL_LIST")' )) 145 146command ( 'rsh! ' .. tempname ) 147 148eq ( test_list , eval ( 'MY_GLOBAL_LIST' )) 149eq ( test_dict , eval ( 'MY_GLOBAL_DICT' )) 150end ) 151 152teardown ( function () 153os . remove ( tempname ) 154command ( 'set shadafile=NONE' ) 155os . remove ( 'Xviminfo' ) 156end ) 157end )