tricks_spec.lua 1.3 KB

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