mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 12:49:11 +00:00
Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
41 lines
1.3 KiB
Lua
41 lines
1.3 KiB
Lua
local t = require('test.unit.testutil')
|
|
local t_eval = require('test.unit.eval.testutil')
|
|
|
|
local describe = t.describe
|
|
local itp = t.gen_itp(t.it)
|
|
|
|
local cimport = t.cimport
|
|
local eq = t.eq
|
|
|
|
local eval0 = t_eval.eval0
|
|
|
|
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h', './src/nvim/memory.h')
|
|
|
|
describe('NULL typval_T', function()
|
|
itp('is produced by $XXX_UNEXISTENT_VAR_XXX', function()
|
|
-- Required for various tests which need to check whether typval_T with NULL
|
|
-- string works correctly. This test checks that unexistent environment
|
|
-- variable produces NULL string, not that some specific environment
|
|
-- variable does not exist. Last bit is left for the test writers.
|
|
local unexistent_env = 'XXX_UNEXISTENT_VAR_XXX'
|
|
while os.getenv(unexistent_env) ~= nil do
|
|
unexistent_env = unexistent_env .. '_XXX'
|
|
end
|
|
local rettv = eval0('$' .. unexistent_env)
|
|
eq(eval.VAR_STRING, rettv.v_type)
|
|
eq(nil, rettv.vval.v_string)
|
|
end)
|
|
|
|
itp('is produced by v:_null_list', function()
|
|
local rettv = eval0('v:_null_list')
|
|
eq(eval.VAR_LIST, rettv.v_type)
|
|
eq(nil, rettv.vval.v_list)
|
|
end)
|
|
|
|
itp('is produced by v:_null_dict', function()
|
|
local rettv = eval0('v:_null_dict')
|
|
eq(eval.VAR_DICT, rettv.v_type)
|
|
eq(nil, rettv.vval.v_dict)
|
|
end)
|
|
end)
|