neovim

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

tricks_spec.lua (1290B)


      1 local t = require('test.unit.testutil')
      2 local t_eval = require('test.unit.eval.testutil')
      3 
      4 local itp = t.gen_itp(it)
      5 
      6 local cimport = t.cimport
      7 local eq = t.eq
      8 
      9 local eval0 = t_eval.eval0
     10 
     11 local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h', './src/nvim/memory.h')
     12 
     13 describe('NULL typval_T', function()
     14  itp('is produced by $XXX_UNEXISTENT_VAR_XXX', function()
     15    -- Required for various tests which need to check whether typval_T with NULL
     16    -- string works correctly. This test checks that unexistent environment
     17    -- variable produces NULL string, not that some specific environment
     18    -- variable does not exist. Last bit is left for the test writers.
     19    local unexistent_env = 'XXX_UNEXISTENT_VAR_XXX'
     20    while os.getenv(unexistent_env) ~= nil do
     21      unexistent_env = unexistent_env .. '_XXX'
     22    end
     23    local rettv = eval0('$' .. unexistent_env)
     24    eq(eval.VAR_STRING, rettv.v_type)
     25    eq(nil, rettv.vval.v_string)
     26  end)
     27 
     28  itp('is produced by v:_null_list', function()
     29    local rettv = eval0('v:_null_list')
     30    eq(eval.VAR_LIST, rettv.v_type)
     31    eq(nil, rettv.vval.v_list)
     32  end)
     33 
     34  itp('is produced by v:_null_dict', function()
     35    local rettv = eval0('v:_null_dict')
     36    eq(eval.VAR_DICT, rettv.v_type)
     37    eq(nil, rettv.vval.v_dict)
     38  end)
     39 end)