neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

074_global_var_in_viminfo_spec.lua (2638B)


      1 -- Tests for storing global variables in the .shada file
      2 
      3 local t = require('test.testutil')
      4 local n = require('test.functional.testnvim')()
      5 
      6 local clear, command, eq, neq, eval, poke_eventloop =
      7  n.clear, n.command, t.eq, t.neq, n.eval, n.poke_eventloop
      8 
      9 describe('storing global variables in ShaDa files', function()
     10  local tempname = 'Xtest-functional-legacy-074'
     11  setup(function()
     12    clear()
     13    os.remove(tempname)
     14  end)
     15 
     16  it('is working', function()
     17    clear { args_rm = { '-i' }, args = { '-i', 'Xviminfo' } }
     18 
     19    local test_dict = { foo = 1, bar = 0, longvarible = 1000 }
     20    local test_list = {
     21      1,
     22      2,
     23      3,
     24      4,
     25      5,
     26      6,
     27      7,
     28      8,
     29      9,
     30      10,
     31      11,
     32      12,
     33      13,
     34      14,
     35      15,
     36      16,
     37      17,
     38      18,
     39      19,
     40      20,
     41      21,
     42      22,
     43      23,
     44      24,
     45      25,
     46      26,
     47      27,
     48      28,
     49      29,
     50      30,
     51      31,
     52      32,
     53      33,
     54      34,
     55      35,
     56      36,
     57      37,
     58      38,
     59      39,
     60      40,
     61      41,
     62      42,
     63      43,
     64      44,
     65      45,
     66      46,
     67      47,
     68      48,
     69      49,
     70      50,
     71      51,
     72      52,
     73      53,
     74      54,
     75      55,
     76      56,
     77      57,
     78      58,
     79      59,
     80      60,
     81      61,
     82      62,
     83      63,
     84      64,
     85      65,
     86      66,
     87      67,
     88      68,
     89      69,
     90      70,
     91      71,
     92      72,
     93      73,
     94      74,
     95      75,
     96      76,
     97      77,
     98      78,
     99      79,
    100      80,
    101      81,
    102      82,
    103      83,
    104      84,
    105      85,
    106      86,
    107      87,
    108      88,
    109      89,
    110      90,
    111      91,
    112      92,
    113      93,
    114      94,
    115      95,
    116      96,
    117      97,
    118      98,
    119      99,
    120      100,
    121    }
    122 
    123    command('set visualbell')
    124    command('set shada+=!')
    125    command("let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}")
    126    -- Store a really long list. Initially this was testing line wrapping in
    127    -- viminfo, but shada files has no line wrapping, no matter how long the
    128    -- list is.
    129    command('let MY_GLOBAL_LIST=range(1, 100)')
    130 
    131    eq(test_dict, eval('MY_GLOBAL_DICT'))
    132    eq(test_list, eval('MY_GLOBAL_LIST'))
    133 
    134    command('wsh! ' .. tempname)
    135    poke_eventloop()
    136 
    137    -- Assert that the shada file exists.
    138    neq(nil, vim.uv.fs_stat(tempname))
    139    command('unlet MY_GLOBAL_DICT')
    140    command('unlet MY_GLOBAL_LIST')
    141    -- Assert that the variables where deleted.
    142    eq(0, eval('exists("MY_GLOBAL_DICT")'))
    143    eq(0, eval('exists("MY_GLOBAL_LIST")'))
    144 
    145    command('rsh! ' .. tempname)
    146 
    147    eq(test_list, eval('MY_GLOBAL_LIST'))
    148    eq(test_dict, eval('MY_GLOBAL_DICT'))
    149  end)
    150 
    151  teardown(function()
    152    os.remove(tempname)
    153    command('set shadafile=NONE')
    154    os.remove('Xviminfo')
    155  end)
    156 end)