aboutsummaryrefslogtreecommitdiff
path: root/test/unit/eval/tricks_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/eval/tricks_spec.lua')
-rw-r--r--test/unit/eval/tricks_spec.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/test/unit/eval/tricks_spec.lua b/test/unit/eval/tricks_spec.lua
index 7f0a445f2c..54029734fb 100644
--- a/test/unit/eval/tricks_spec.lua
+++ b/test/unit/eval/tricks_spec.lua
@@ -6,13 +6,17 @@ local to_cstr = helpers.to_cstr
local ffi = helpers.ffi
local eq = helpers.eq
-local eval = cimport('./src/nvim/eval.h', './src/nvim/memory.h')
+local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
+ './src/nvim/memory.h')
-local eval_expr = function(expr)
- return ffi.gc(eval.eval_expr(to_cstr(expr), nil), function(tv)
- eval.tv_clear(tv)
- eval.xfree(tv)
- end)
+local eval0 = function(expr)
+ local tv = ffi.gc(ffi.new('typval_T', {v_type=eval.VAR_UNKNOWN}),
+ eval.tv_clear)
+ if eval.eval0(to_cstr(expr), tv, nil, true) == 0 then
+ return nil
+ else
+ return tv
+ end
end
describe('NULL typval_T', function()
@@ -25,19 +29,19 @@ describe('NULL typval_T', function()
while os.getenv(unexistent_env) ~= nil do
unexistent_env = unexistent_env .. '_XXX'
end
- local rettv = eval_expr('$' .. unexistent_env)
+ 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 = eval_expr('v:_null_list')
+ 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 = eval_expr('v:_null_dict')
+ local rettv = eval0('v:_null_dict')
eq(eval.VAR_DICT, rettv.v_type)
eq(nil, rettv.vval.v_dict)
end)