aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/null_spec.lua
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-08 22:33:21 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-08 22:36:20 -0400
commit0d0eeff8a34b01db93fb271fbeac3ad2d372a0e0 (patch)
tree9ad6ef39f8578c2c22bd0cf3ddd5afeb18bcd9c1 /test/functional/eval/null_spec.lua
parentec273a2c6ba055810539f2d58353c9c0fc8db320 (diff)
downloadrneovim-0d0eeff8a34b01db93fb271fbeac3ad2d372a0e0.tar.gz
rneovim-0d0eeff8a34b01db93fb271fbeac3ad2d372a0e0.tar.bz2
rneovim-0d0eeff8a34b01db93fb271fbeac3ad2d372a0e0.zip
eval: add v:_null_string
Replacement for Vim's test_null_string(). Vim uses it to verify that its codebase handles null strings. Preparation for the Test_null_list() in patch v8.2.1822. Use v:_null_string, not non-existent env var, for null string tests. Mention v:_null_string in id() because id(v:_null_string) returns (nil).
Diffstat (limited to 'test/functional/eval/null_spec.lua')
-rw-r--r--test/functional/eval/null_spec.lua26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua
index fa8f7d873f..d403fbc878 100644
--- a/test/functional/eval/null_spec.lua
+++ b/test/functional/eval/null_spec.lua
@@ -14,7 +14,8 @@ describe('NULL', function()
clear()
command('let L = v:_null_list')
command('let D = v:_null_dict')
- command('let S = $XXX_NONEXISTENT_VAR_XXX')
+ command('let S = v:_null_string')
+ command('let V = $XXX_NONEXISTENT_VAR_XXX')
end)
local tmpfname = 'Xtest-functional-viml-null'
after_each(function()
@@ -129,6 +130,7 @@ describe('NULL', function()
null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, 0)
null_test('is accepted by :cexpr', 'cexpr L', 0)
null_test('is accepted by :lexpr', 'lexpr L', 0)
+ null_expr_test('does not crash execute()', 'execute(L)', 0, '')
end)
describe('dict', function()
it('does not crash when indexing NULL dict', function()
@@ -142,4 +144,26 @@ describe('NULL', function()
null_expr_test('makes map() return v:_null_dict', 'map(D, "v:val") is# D', 0, 1)
null_expr_test('makes filter() return v:_null_dict', 'filter(D, "1") is# D', 0, 1)
end)
+ describe('string', function()
+ null_test('does not crash :echomsg', 'echomsg S', 0)
+ null_test('does not crash :execute', 'execute S', 0)
+ null_expr_test('does not crash execute()', 'execute(S)', 0, '')
+ null_expr_test('makes executable() error out', 'executable(S)', 'E928: String required', 0)
+ null_expr_test('does not crash filereadable()', 'filereadable(S)', 0, 0)
+ null_expr_test('does not crash filewritable()', 'filewritable(S)', 0, 0)
+ null_expr_test('does not crash fnamemodify()', 'fnamemodify(S, S)', 0, '')
+ null_expr_test('does not crash getfperm()', 'getfperm(S)', 0, '')
+ null_expr_test('does not crash getfsize()', 'getfsize(S)', 0, -1)
+ null_expr_test('does not crash getftime()', 'getftime(S)', 0, -1)
+ null_expr_test('does not crash getftype()', 'getftype(S)', 0, '')
+ null_expr_test('does not crash glob()', 'glob(S)', 0, '')
+ null_expr_test('does not crash globpath()', 'globpath(S, S)', 0, '')
+ null_expr_test('does not crash mkdir()', 'mkdir(S)', 0, 0)
+ null_expr_test('does not crash sort()', 'sort(["b", S, "a"])', 0, {'', 'a', 'b'})
+ null_expr_test('does not crash split()', 'split(S)', 0, {})
+
+ null_test('can be used to set an option', 'let &grepprg = S', 0)
+
+ null_expr_test('is equal to non-existent variable', 'S == V', 0, 1)
+ end)
end)