diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-04-17 20:24:23 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-04-17 20:24:23 -0400 |
commit | 007d573147bb9086c63e779b1db3938690037db8 (patch) | |
tree | 8a0833743202d0e6be899fe65b50a47197c0e40a /test/unit/eval/tricks_spec.lua | |
parent | 83c683f5e15867c2e2889442860e91fd1074b4e1 (diff) | |
parent | a64114eba017c0db3d1849186c9c54fb09308761 (diff) | |
download | rneovim-007d573147bb9086c63e779b1db3938690037db8.tar.gz rneovim-007d573147bb9086c63e779b1db3938690037db8.tar.bz2 rneovim-007d573147bb9086c63e779b1db3938690037db8.zip |
Merge pull request #4131 from ZyX-I/json-functions
Add JSON support
Diffstat (limited to 'test/unit/eval/tricks_spec.lua')
-rw-r--r-- | test/unit/eval/tricks_spec.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/eval/tricks_spec.lua b/test/unit/eval/tricks_spec.lua new file mode 100644 index 0000000000..4c5184995c --- /dev/null +++ b/test/unit/eval/tricks_spec.lua @@ -0,0 +1,43 @@ +local helpers = require('test.unit.helpers') + +local cimport = helpers.cimport +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_expr = function(expr) + return ffi.gc(eval.eval_expr(to_cstr(expr), nil), function(tv) + eval.clear_tv(tv) + eval.xfree(tv) + end) +end + +describe('NULL typval_T', function() + it('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 = eval_expr('$' .. unexistent_env) + eq(eval.VAR_STRING, rettv.v_type) + eq(nil, rettv.vval.v_string) + end) + + it('is produced by v:_null_list', function() + local rettv = eval_expr('v:_null_list') + eq(eval.VAR_LIST, rettv.v_type) + eq(nil, rettv.vval.v_list) + end) + + it('is produced by v:_null_dict', function() + local rettv = eval_expr('v:_null_dict') + eq(eval.VAR_DICT, rettv.v_type) + eq(nil, rettv.vval.v_dict) + end) +end) |