aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/sort_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2018-04-15 18:45:12 +0300
committerZyX <kp-pav@yandex.ru>2018-04-15 18:45:12 +0300
commitf8d574225b61fc4bc0fd52990deda4825f62dc8f (patch)
treebceb3f4a230d020da93fe609b233c2e2aa7b0eba /test/functional/eval/sort_spec.lua
parent6f19b9f4e19d12aea23ac61c889aa122bc2576eb (diff)
downloadrneovim-f8d574225b61fc4bc0fd52990deda4825f62dc8f.tar.gz
rneovim-f8d574225b61fc4bc0fd52990deda4825f62dc8f.tar.bz2
rneovim-f8d574225b61fc4bc0fd52990deda4825f62dc8f.zip
eval: Silence PVS/V547: E882 may be triggered
I failed to deduce why analyzer thinks E882 may not be triggered, though conditions for triggering it are strange: it would trigger E882 only in the single case “function returned non-number”. Cases “function thrown exception”, or “built-in sorter encountered error” will neither yield E882 nor stop sort()/uniq(). Note though that searching test code revealed that neither E702 nor E882 are not tested anywhere.
Diffstat (limited to 'test/functional/eval/sort_spec.lua')
-rw-r--r--test/functional/eval/sort_spec.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/functional/eval/sort_spec.lua b/test/functional/eval/sort_spec.lua
index 4e5a0afba4..82557575ce 100644
--- a/test/functional/eval/sort_spec.lua
+++ b/test/functional/eval/sort_spec.lua
@@ -8,6 +8,7 @@ local meths = helpers.meths
local funcs = helpers.funcs
local command = helpers.command
local exc_exec = helpers.exc_exec
+local redir_exec = helpers.redir_exec
before_each(clear)
@@ -38,4 +39,18 @@ describe('sort()', function()
eq('[-1.0e-4, function(\'tr\'), v:true, v:false, v:null, [], {\'a\': 42}, \'check\', 1.0e-4]',
eval('string(g:list)'))
end)
+
+ it('can yield E702 and stop sorting after that', function()
+ command([[
+ function Cmp(a, b)
+ if type(a:a) == type([]) || type(a:b) == type([])
+ return []
+ endif
+ return (a:a > a:b) - (a:a < a:b)
+ endfunction
+ ]])
+ eq('\nE745: Using a List as a Number\nE702: Sort compare function failed',
+ redir_exec('let sl = sort([1, 0, [], 3, 2], "Cmp")'))
+ eq({1, 0, {}, 3, 2}, meths.get_var('sl'))
+ end)
end)