robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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