From 82e6cac5f9d437da5aeb8c4cf51945cfeb5922ff Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 18 Sep 2016 01:54:23 +0300 Subject: functests: Add null_spec.lua from #4615 For now it is full of FIXMEs and tests for incorrect behaviour. Sorted out to have FIXMEs in one place, commented crashing tests in other and correctly working tests in the third one. --- test/functional/eval/null_spec.lua | 141 +++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 test/functional/eval/null_spec.lua (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua new file mode 100644 index 0000000000..9a35905be0 --- /dev/null +++ b/test/functional/eval/null_spec.lua @@ -0,0 +1,141 @@ +local helpers = require('test.functional.helpers')(after_each) + +local curbufmeths = helpers.curbufmeths +local redir_exec = helpers.redir_exec +local exc_exec = helpers.exc_exec +local command = helpers.command +local clear = helpers.clear +local meths = helpers.meths +local funcs = helpers.funcs +local eq = helpers.eq + +describe('NULL', function() + before_each(function() + clear() + command('let L = v:_null_list') + command('let D = v:_null_dict') + command('let S = $XXX_NONEXISTENT_VAR_XXX') + end) + local tmpfname = 'Xtest-functional-viml-null' + after_each(function() + os.remove(tmpfname) + end) + describe('list', function() + local null_list_test = function(name, cmd, err) + it(name, function() + eq(err, exc_exec(cmd)) + end) + end + local null_list_expr_test = function(name, expr, err, val, after) + it(name, function() + eq((err == 0) and ('') or ('\n' .. err), + redir_exec('let g:_var = ' .. expr)) + if val == nil then + eq(0, funcs.exists('g:_var')) + else + eq(val, meths.get_var('_var')) + end + if after ~= nil then + after() + end + end) + end + + -- Incorrect behaviour + + -- FIXME map() should not return 0 without error + null_list_expr_test('does not crash map()', 'map(L, "v:val")', 0, 0) + -- FIXME map() should not return 0 without error + null_list_expr_test('does not crash filter()', 'filter(L, "1")', 0, 0) + -- FIXME map() should at least return L + null_list_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 0) + -- FIXME filter() should at least return L + null_list_expr_test('makes filter() return v:_null_list', 'map(L, "1") is# L', 0, 0) + -- FIXME add() should not return 1 at all + null_list_expr_test('does not crash add()', 'add(L, 0)', 0, 1) + -- FIXME extend() should not return 0 without error + null_list_expr_test('does not crash extend()', 'extend(L, [1])', 0, 0) + -- FIXME extend() should not return 0 at all + null_list_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, 0) + -- FIXME Should return 1 + null_list_expr_test('is equal to itself', 'L == L', 0, 0) + -- FIXME Should return 0 + null_list_expr_test('is not not equal to itself', 'L != L', 0, 1) + -- FIXME Should return empty list + null_list_expr_test('can be added to itself', '(L + L)', 'E15: Invalid expression: (L + L)', nil) + -- FIXME Should return [1] + null_list_expr_test('can be added to non-empty list (reversed)', '(L + [1])', + 'E15: Invalid expression: (L + [1])', nil) + -- FIXME Should return [1] + null_list_expr_test('can be added to non-empty list', '([1] + L)', + 'E15: Invalid expression: ([1] + L)', nil) + -- FIXME Should return 1 + null_list_expr_test('counts correctly', 'count([L], L)', 0, 0) + -- FIXME should be accepted by inputlist() + null_list_expr_test('is accepted as an empty list by inputlist()', + '[feedkeys("\\n"), inputlist(L)]', 'E686: Argument of inputlist() must be a List', {0, 0}) + -- FIXME should be accepted by writefile(), return {0, {}} + null_list_expr_test('is accepted as an empty list by writefile()', + ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), + 'E484: Can\'t open file ' .. tmpfname, {0, {}}) + -- FIXME should give error message + null_list_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) + -- FIXME should return 0 + null_list_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) + -- FIXME should return 0 + null_list_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1) + -- FIXME should return 0 + null_list_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1) + -- FIXME should return empty list or error out + null_list_expr_test('is accepted by sort()', 'sort(L)', 0, 0) + -- FIXME Should return 1 + null_list_expr_test('is accepted by sort()', 'sort(L) is L', 0, 0) + -- FIXME should not error out + null_list_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') + -- FIXME should not error out + null_list_test('is accepted by :lexpr', 'lexpr L', 'Vim(lexpr):E777: String or List expected') + -- FIXME should not error out + null_list_test('is accepted by :for', 'for x in L|throw x|endfor', 'Vim(for):E714: List required') + + -- Subjectable behaviour + + -- FIXME Should return 1 + null_list_expr_test('is equal to empty list', 'L == []', 0, 0) + -- FIXME Should return 1 + null_list_expr_test('is equal to empty list (reverse order)', '[] == L', 0, 0) + -- FIXME Should return 1 + null_list_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) + + -- Crashes + + -- null_list_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) + -- null_list_expr_test('does not crash setline', 'setline(1, L)', 0, 0) + -- null_list_expr_test('does not crash system()', 'system("cat", L)', 0, '') + -- null_list_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) + + -- Correct behaviour + null_list_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() + eq({''}, curbufmeths.get_lines(0, -1, false)) + end) + null_list_expr_test('is identical to itself', 'L is L', 0, 1) + null_list_expr_test('can be sliced', 'L[:]', 0, {}) + null_list_expr_test('can be copied', 'copy(L)', 0, {}) + null_list_expr_test('can be deepcopied', 'deepcopy(L)', 0, {}) + null_list_expr_test('does not crash when indexed', 'L[1]', + 'E684: list index out of range: 1\nE15: Invalid expression: L[1]', nil) + null_list_expr_test('does not crash call()', 'call("arglistid", L)', 0, 0) + null_list_expr_test('does not crash col()', 'col(L)', 0, 0) + null_list_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0) + null_list_expr_test('does not crash line()', 'line(L)', 0, 0) + null_list_expr_test('does not crash count()', 'count(L, 1)', 0, 0) + null_list_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1) + null_list_expr_test('is empty', 'empty(L)', 0, 1) + null_list_expr_test('does not crash get()', 'get(L, 1, 10)', 0, 10) + null_list_expr_test('has zero length', 'len(L)', 0, 0) + null_list_expr_test('is accepted as an empty list by max()', 'max(L)', 0, 0) + null_list_expr_test('is accepted as an empty list by min()', 'min(L)', 0, 0) + null_list_expr_test('is stringified correctly', 'string(L)', 0, '[]') + null_list_expr_test('is JSON encoded correctly', 'json_encode(L)', 0, '[]') + null_list_test('does not crash lockvar', 'lockvar! L', 0) + end) +end) -- cgit From f80a00469fdba8a3dec0edae30c911d050485055 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 18 Sep 2016 01:59:07 +0300 Subject: eval/typval: Make tv_list_concat handle NULL lists correctly Fixes some FIXMEs in eval/null_spec.lua. --- test/functional/eval/null_spec.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index 9a35905be0..ccdd1ce34c 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -61,14 +61,6 @@ describe('NULL', function() null_list_expr_test('is equal to itself', 'L == L', 0, 0) -- FIXME Should return 0 null_list_expr_test('is not not equal to itself', 'L != L', 0, 1) - -- FIXME Should return empty list - null_list_expr_test('can be added to itself', '(L + L)', 'E15: Invalid expression: (L + L)', nil) - -- FIXME Should return [1] - null_list_expr_test('can be added to non-empty list (reversed)', '(L + [1])', - 'E15: Invalid expression: (L + [1])', nil) - -- FIXME Should return [1] - null_list_expr_test('can be added to non-empty list', '([1] + L)', - 'E15: Invalid expression: ([1] + L)', nil) -- FIXME Should return 1 null_list_expr_test('counts correctly', 'count([L], L)', 0, 0) -- FIXME should be accepted by inputlist() @@ -137,5 +129,9 @@ describe('NULL', function() null_list_expr_test('is stringified correctly', 'string(L)', 0, '[]') null_list_expr_test('is JSON encoded correctly', 'json_encode(L)', 0, '[]') null_list_test('does not crash lockvar', 'lockvar! L', 0) + null_list_expr_test('can be added to itself', '(L + L)', 0, {}) + null_list_expr_test('can be added to itself', '(L + L) is L', 0, 1) + null_list_expr_test('can be added to non-empty list', '([1] + L)', 0, {1}) + null_list_expr_test('can be added to non-empty list (reversed)', '(L + [1])', 0, {1}) end) end) -- cgit From b3672ae2fced4715963442d2e19048f8fadbe0b8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Oct 2016 04:34:30 +0300 Subject: eval/typval: Add tv_list_equal() tests, compare NULL lists equal --- test/functional/eval/null_spec.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index ccdd1ce34c..e587ede319 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -57,12 +57,6 @@ describe('NULL', function() null_list_expr_test('does not crash extend()', 'extend(L, [1])', 0, 0) -- FIXME extend() should not return 0 at all null_list_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, 0) - -- FIXME Should return 1 - null_list_expr_test('is equal to itself', 'L == L', 0, 0) - -- FIXME Should return 0 - null_list_expr_test('is not not equal to itself', 'L != L', 0, 1) - -- FIXME Should return 1 - null_list_expr_test('counts correctly', 'count([L], L)', 0, 0) -- FIXME should be accepted by inputlist() null_list_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 'E686: Argument of inputlist() must be a List', {0, 0}) @@ -133,5 +127,8 @@ describe('NULL', function() null_list_expr_test('can be added to itself', '(L + L) is L', 0, 1) null_list_expr_test('can be added to non-empty list', '([1] + L)', 0, {1}) null_list_expr_test('can be added to non-empty list (reversed)', '(L + [1])', 0, {1}) + null_list_expr_test('is equal to itself', 'L == L', 0, 1) + null_list_expr_test('is not not equal to itself', 'L != L', 0, 0) + null_list_expr_test('counts correctly', 'count([L], L)', 0, 1) end) end) -- cgit From 1e3e302dc2bdced563ecd2c3fb101af31f72b3df Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 4 Dec 2016 21:58:19 +0300 Subject: eval: Move part of dictwatcher* functions to eval/typval --- test/functional/eval/null_spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index e587ede319..f72d05f2a3 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -80,8 +80,7 @@ describe('NULL', function() null_list_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') -- FIXME should not error out null_list_test('is accepted by :lexpr', 'lexpr L', 'Vim(lexpr):E777: String or List expected') - -- FIXME should not error out - null_list_test('is accepted by :for', 'for x in L|throw x|endfor', 'Vim(for):E714: List required') + null_list_test('is accepted by :for', 'for x in L|throw x|endfor', 0) -- Subjectable behaviour -- cgit From 38dd81c136c2edbda66614622a4747bf1785af94 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Mar 2017 02:15:17 +0300 Subject: eval/typval: Fix SEGV in test_alot.vim test --- test/functional/eval/null_spec.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index f72d05f2a3..3b361ceeda 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -130,4 +130,10 @@ describe('NULL', function() null_list_expr_test('is not not equal to itself', 'L != L', 0, 0) null_list_expr_test('counts correctly', 'count([L], L)', 0, 1) end) + describe('dict', function() + it('does not crash when indexing NULL dict', function() + eq('\nE716: Key not present in Dictionary: test\nE15: Invalid expression: v:_null_dict.test', + redir_exec('echo v:_null_dict.test')) + end) + end) end) -- cgit From fa852e7cdc365b6fcd39d677f4067963274c44c3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 13 Mar 2017 14:17:35 +0300 Subject: eval: Fix extend() behaviour with NULL lists and dictionaries Ref #4615 Ref vim/vim#768 --- test/functional/eval/null_spec.lua | 147 ++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 74 deletions(-) (limited to 'test/functional/eval/null_spec.lua') diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index 3b361ceeda..6fd30caec9 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -20,120 +20,119 @@ describe('NULL', function() after_each(function() os.remove(tmpfname) end) + local null_test = function(name, cmd, err) + it(name, function() + eq(err, exc_exec(cmd)) + end) + end + local null_expr_test = function(name, expr, err, val, after) + it(name, function() + eq((err == 0) and ('') or ('\n' .. err), + redir_exec('let g:_var = ' .. expr)) + if val == nil then + eq(0, funcs.exists('g:_var')) + else + eq(val, meths.get_var('_var')) + end + if after ~= nil then + after() + end + end) + end describe('list', function() - local null_list_test = function(name, cmd, err) - it(name, function() - eq(err, exc_exec(cmd)) - end) - end - local null_list_expr_test = function(name, expr, err, val, after) - it(name, function() - eq((err == 0) and ('') or ('\n' .. err), - redir_exec('let g:_var = ' .. expr)) - if val == nil then - eq(0, funcs.exists('g:_var')) - else - eq(val, meths.get_var('_var')) - end - if after ~= nil then - after() - end - end) - end - -- Incorrect behaviour -- FIXME map() should not return 0 without error - null_list_expr_test('does not crash map()', 'map(L, "v:val")', 0, 0) + null_expr_test('does not crash map()', 'map(L, "v:val")', 0, 0) -- FIXME map() should not return 0 without error - null_list_expr_test('does not crash filter()', 'filter(L, "1")', 0, 0) + null_expr_test('does not crash filter()', 'filter(L, "1")', 0, 0) -- FIXME map() should at least return L - null_list_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 0) + null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 0) -- FIXME filter() should at least return L - null_list_expr_test('makes filter() return v:_null_list', 'map(L, "1") is# L', 0, 0) + null_expr_test('makes filter() return v:_null_list', 'map(L, "1") is# L', 0, 0) -- FIXME add() should not return 1 at all - null_list_expr_test('does not crash add()', 'add(L, 0)', 0, 1) - -- FIXME extend() should not return 0 without error - null_list_expr_test('does not crash extend()', 'extend(L, [1])', 0, 0) - -- FIXME extend() should not return 0 at all - null_list_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, 0) + null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) + null_expr_test('does not crash extend()', 'extend(L, [1])', 'E742: Cannot change value of extend() argument', 0) + null_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, {1}) -- FIXME should be accepted by inputlist() - null_list_expr_test('is accepted as an empty list by inputlist()', + null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 'E686: Argument of inputlist() must be a List', {0, 0}) -- FIXME should be accepted by writefile(), return {0, {}} - null_list_expr_test('is accepted as an empty list by writefile()', + null_expr_test('is accepted as an empty list by writefile()', ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), 'E484: Can\'t open file ' .. tmpfname, {0, {}}) -- FIXME should give error message - null_list_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) + null_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) -- FIXME should return 0 - null_list_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) + null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) -- FIXME should return 0 - null_list_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1) + null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1) -- FIXME should return 0 - null_list_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1) + null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1) -- FIXME should return empty list or error out - null_list_expr_test('is accepted by sort()', 'sort(L)', 0, 0) + null_expr_test('is accepted by sort()', 'sort(L)', 0, 0) -- FIXME Should return 1 - null_list_expr_test('is accepted by sort()', 'sort(L) is L', 0, 0) + null_expr_test('is accepted by sort()', 'sort(L) is L', 0, 0) -- FIXME should not error out - null_list_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') + null_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') -- FIXME should not error out - null_list_test('is accepted by :lexpr', 'lexpr L', 'Vim(lexpr):E777: String or List expected') - null_list_test('is accepted by :for', 'for x in L|throw x|endfor', 0) + null_test('is accepted by :lexpr', 'lexpr L', 'Vim(lexpr):E777: String or List expected') + null_test('is accepted by :for', 'for x in L|throw x|endfor', 0) -- Subjectable behaviour -- FIXME Should return 1 - null_list_expr_test('is equal to empty list', 'L == []', 0, 0) + null_expr_test('is equal to empty list', 'L == []', 0, 0) -- FIXME Should return 1 - null_list_expr_test('is equal to empty list (reverse order)', '[] == L', 0, 0) + null_expr_test('is equal to empty list (reverse order)', '[] == L', 0, 0) -- FIXME Should return 1 - null_list_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) + null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) -- Crashes - -- null_list_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) - -- null_list_expr_test('does not crash setline', 'setline(1, L)', 0, 0) - -- null_list_expr_test('does not crash system()', 'system("cat", L)', 0, '') - -- null_list_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) + -- null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) + -- null_expr_test('does not crash setline', 'setline(1, L)', 0, 0) + -- null_expr_test('does not crash system()', 'system("cat", L)', 0, '') + -- null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) -- Correct behaviour - null_list_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() + null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() eq({''}, curbufmeths.get_lines(0, -1, false)) end) - null_list_expr_test('is identical to itself', 'L is L', 0, 1) - null_list_expr_test('can be sliced', 'L[:]', 0, {}) - null_list_expr_test('can be copied', 'copy(L)', 0, {}) - null_list_expr_test('can be deepcopied', 'deepcopy(L)', 0, {}) - null_list_expr_test('does not crash when indexed', 'L[1]', + null_expr_test('is identical to itself', 'L is L', 0, 1) + null_expr_test('can be sliced', 'L[:]', 0, {}) + null_expr_test('can be copied', 'copy(L)', 0, {}) + null_expr_test('can be deepcopied', 'deepcopy(L)', 0, {}) + null_expr_test('does not crash when indexed', 'L[1]', 'E684: list index out of range: 1\nE15: Invalid expression: L[1]', nil) - null_list_expr_test('does not crash call()', 'call("arglistid", L)', 0, 0) - null_list_expr_test('does not crash col()', 'col(L)', 0, 0) - null_list_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0) - null_list_expr_test('does not crash line()', 'line(L)', 0, 0) - null_list_expr_test('does not crash count()', 'count(L, 1)', 0, 0) - null_list_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1) - null_list_expr_test('is empty', 'empty(L)', 0, 1) - null_list_expr_test('does not crash get()', 'get(L, 1, 10)', 0, 10) - null_list_expr_test('has zero length', 'len(L)', 0, 0) - null_list_expr_test('is accepted as an empty list by max()', 'max(L)', 0, 0) - null_list_expr_test('is accepted as an empty list by min()', 'min(L)', 0, 0) - null_list_expr_test('is stringified correctly', 'string(L)', 0, '[]') - null_list_expr_test('is JSON encoded correctly', 'json_encode(L)', 0, '[]') - null_list_test('does not crash lockvar', 'lockvar! L', 0) - null_list_expr_test('can be added to itself', '(L + L)', 0, {}) - null_list_expr_test('can be added to itself', '(L + L) is L', 0, 1) - null_list_expr_test('can be added to non-empty list', '([1] + L)', 0, {1}) - null_list_expr_test('can be added to non-empty list (reversed)', '(L + [1])', 0, {1}) - null_list_expr_test('is equal to itself', 'L == L', 0, 1) - null_list_expr_test('is not not equal to itself', 'L != L', 0, 0) - null_list_expr_test('counts correctly', 'count([L], L)', 0, 1) + null_expr_test('does not crash call()', 'call("arglistid", L)', 0, 0) + null_expr_test('does not crash col()', 'col(L)', 0, 0) + null_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0) + null_expr_test('does not crash line()', 'line(L)', 0, 0) + null_expr_test('does not crash count()', 'count(L, 1)', 0, 0) + null_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1) + null_expr_test('is empty', 'empty(L)', 0, 1) + null_expr_test('does not crash get()', 'get(L, 1, 10)', 0, 10) + null_expr_test('has zero length', 'len(L)', 0, 0) + null_expr_test('is accepted as an empty list by max()', 'max(L)', 0, 0) + null_expr_test('is accepted as an empty list by min()', 'min(L)', 0, 0) + null_expr_test('is stringified correctly', 'string(L)', 0, '[]') + null_expr_test('is JSON encoded correctly', 'json_encode(L)', 0, '[]') + null_test('does not crash lockvar', 'lockvar! L', 0) + null_expr_test('can be added to itself', '(L + L)', 0, {}) + null_expr_test('can be added to itself', '(L + L) is L', 0, 1) + null_expr_test('can be added to non-empty list', '([1] + L)', 0, {1}) + null_expr_test('can be added to non-empty list (reversed)', '(L + [1])', 0, {1}) + null_expr_test('is equal to itself', 'L == L', 0, 1) + null_expr_test('is not not equal to itself', 'L != L', 0, 0) + null_expr_test('counts correctly', 'count([L], L)', 0, 1) end) describe('dict', function() it('does not crash when indexing NULL dict', function() eq('\nE716: Key not present in Dictionary: test\nE15: Invalid expression: v:_null_dict.test', redir_exec('echo v:_null_dict.test')) end) + null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0) + null_expr_test('makes extend do nothing', 'extend({1: 2}, D)', 0, {['1']=2}) end) end) -- cgit