diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-04-27 09:25:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 09:25:02 +0200 |
commit | 53f11dcfc7139fe6c8a6b114db4bfec5d91005a9 (patch) | |
tree | e9bfbaf10fc6681bbbcba0a0eabdce8a6f6840b5 /test/functional | |
parent | 009ccfe170ada2c78ca7feabda567a7e901fb30b (diff) | |
parent | 4ce8521ee4a72e050bd187c2986708c5f98c7442 (diff) | |
download | rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.gz rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.bz2 rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.zip |
Merge #8218 'Fix errors reported by PVS'
closes #4983
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/eval/sort_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/eval/uniq_spec.lua | 31 |
2 files changed, 46 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) diff --git a/test/functional/eval/uniq_spec.lua b/test/functional/eval/uniq_spec.lua new file mode 100644 index 0000000000..0e7a013e32 --- /dev/null +++ b/test/functional/eval/uniq_spec.lua @@ -0,0 +1,31 @@ +local helpers = require('test.functional.helpers')(after_each) + +local eq = helpers.eq +local clear = helpers.clear +local meths = helpers.meths +local command = helpers.command +local exc_exec = helpers.exc_exec +local redir_exec = helpers.redir_exec + +before_each(clear) + +describe('uniq()', function() + it('errors out when processing special values', function() + eq('Vim(call):E907: Using a special value as a Float', + exc_exec('call uniq([v:true, v:false], "f")')) + end) + + it('can yield E882 and stop filtering 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\nE882: Uniq compare function failed', + redir_exec('let fl = uniq([0, 0, [], 1, 1], "Cmp")')) + eq({0, {}, 1, 1}, meths.get_var('fl')) + end) +end) |