From 274f32d42e61e6f6c76b9ca499f5b79f256a481a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:39:51 +0300 Subject: *: Start hiding list implementation Most of files, except for eval.c and eval/* were only processed by perl. --- test/functional/eval/null_spec.lua | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 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 b67158eb22..992bc6b39f 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -42,10 +42,6 @@ describe('NULL', function() describe('list', function() -- Incorrect behaviour - -- FIXME add() should not return 1 at all - 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_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 'E686: Argument of inputlist() must be a List', {0, 0}) @@ -53,18 +49,12 @@ describe('NULL', function() 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_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) -- FIXME should return 0 null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) -- FIXME should return 0 null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1) -- FIXME should return 0 null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1) - -- FIXME should return empty list or error out - null_expr_test('is accepted by sort()', 'sort(L)', 0, 0) - -- FIXME Should return 1 - null_expr_test('is accepted by sort()', 'sort(L) is L', 0, 0) -- FIXME should not error out null_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') -- FIXME should not error out @@ -80,13 +70,6 @@ describe('NULL', function() -- FIXME Should return 1 null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) - -- Crashes - - -- 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_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() eq({''}, curbufmeths.get_lines(0, -1, false)) @@ -122,6 +105,22 @@ describe('NULL', function() null_expr_test('counts correctly', 'count([L], L)', 0, 1) null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 1) null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1) + null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items') + -- FIXME fix test results + null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) + null_expr_test('makes insert() error out', 'insert(L, 1)', '', nil) + null_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) + null_expr_test('makes reverse() error out', 'reverse(L)', '', nil) + null_expr_test('is accepted by sort()', 'sort(L)', 0, 0) + null_expr_test('makes sort() return itself', 'sort(L) is L', 0, 0) + 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}) + null_expr_test('makes join() return empty string', 'join(L, "")', 0, '') + null_expr_test('makes msgpackdump() return empty list', 'msgpackdump(L)', 0, {}) + null_expr_test('does not crash system()', 'system("cat", L)', 0, '') + null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) + null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) + null_expr_test('does not crash setline', 'setline(1, L)', 0, 0) end) describe('dict', function() it('does not crash when indexing NULL dict', function() -- cgit From 21745d72b8c24c7f19dea5d53384da4875c43e74 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:50:52 +0300 Subject: eval: Fix inputlist() --- test/functional/eval/null_spec.lua | 4 +--- 1 file changed, 1 insertion(+), 3 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 992bc6b39f..20f9c70a41 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -42,9 +42,6 @@ describe('NULL', function() describe('list', function() -- Incorrect behaviour - -- FIXME should be accepted 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_expr_test('is accepted as an empty list by writefile()', ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), @@ -106,6 +103,7 @@ describe('NULL', function() null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 1) null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1) null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items') + null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 0, 0) -- FIXME fix test results null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) null_expr_test('makes insert() error out', 'insert(L, 1)', '', nil) -- cgit From 5c1ddb5078c90f69c7225a7b2e74ccb914dcdd6a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:54:21 +0300 Subject: eval: Fix writefile() --- test/functional/eval/null_spec.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 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 20f9c70a41..7452185208 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -42,10 +42,6 @@ describe('NULL', function() describe('list', function() -- Incorrect behaviour - -- FIXME should be accepted by writefile(), return {0, {}} - 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 return 0 null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) -- FIXME should return 0 @@ -104,6 +100,9 @@ describe('NULL', function() null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1) null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items') null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 0, 0) + null_expr_test('is accepted as an empty list by writefile()', + ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), + 0, {0, {}}) -- FIXME fix test results null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) null_expr_test('makes insert() error out', 'insert(L, 1)', '', nil) -- cgit From ac4bbf55f6d6b9b252dd90fe800626850022b690 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:04:43 +0300 Subject: *: Hide list implementation in other files as well --- test/functional/eval/null_spec.lua | 2 ++ 1 file changed, 2 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 7452185208..d85f5297d2 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -118,6 +118,8 @@ describe('NULL', function() null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) null_expr_test('does not crash setline', 'setline(1, L)', 0, 0) + null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0) + -- FIXME Add test for complete(, L) end) describe('dict', function() it('does not crash when indexing NULL dict', function() -- cgit From f572bd7e4e15a99cc19244a4411c6a596309f489 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:24:11 +0300 Subject: eval,functests: Fix tests and complete() and setline() behaviour --- test/functional/eval/null_spec.lua | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 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 d85f5297d2..3ab9e746a4 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -67,6 +67,9 @@ describe('NULL', function() null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() eq({''}, curbufmeths.get_lines(0, -1, false)) end) + null_expr_test('does not crash setline()', 'setline(1, L)', 0, 0, function() + eq({''}, curbufmeths.get_lines(0, -1, false)) + end) 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, {}) @@ -99,17 +102,20 @@ describe('NULL', function() null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 1) null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1) null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items') - null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 0, 0) + null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', + 'Type number and or click with mouse (empty cancels): ', {0, 0}) null_expr_test('is accepted as an empty list by writefile()', ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), 0, {0, {}}) - -- FIXME fix test results null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) - null_expr_test('makes insert() error out', 'insert(L, 1)', '', nil) - null_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0) - null_expr_test('makes reverse() error out', 'reverse(L)', '', nil) - null_expr_test('is accepted by sort()', 'sort(L)', 0, 0) - null_expr_test('makes sort() return itself', 'sort(L) is L', 0, 0) + null_expr_test('makes insert() error out', 'insert(L, 1)', + 'E742: Cannot change value of insert() argument', 0) + null_expr_test('does not crash remove()', 'remove(L, 0)', + 'E742: Cannot change value of remove() argument', 0) + null_expr_test('makes reverse() error out', 'reverse(L)', + 'E742: Cannot change value of reverse() argument', 0) + null_expr_test('makes sort() error out', 'sort(L)', + 'E742: Cannot change value of sort() argument', 0) 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}) null_expr_test('makes join() return empty string', 'join(L, "")', 0, '') @@ -117,9 +123,12 @@ describe('NULL', function() null_expr_test('does not crash system()', 'system("cat", L)', 0, '') null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0) null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {}) - null_expr_test('does not crash setline', 'setline(1, L)', 0, 0) null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0) - -- FIXME Add test for complete(, L) + null_expr_test('does not make complete() crash or error out', + 'execute(":normal i\\=complete(1, L)[-1]\\n")', + '', '\n', function() + eq({''}, curbufmeths.get_lines(0, -1, false)) + end) end) describe('dict', function() it('does not crash when indexing NULL dict', function() -- cgit From 5008205a3e1eef61396e457e5091eb1341b98278 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:28:18 +0300 Subject: eval: Fix setmatches(), setqflist() and setloclist() --- 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 3ab9e746a4..30c6d3d450 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -42,12 +42,6 @@ describe('NULL', function() describe('list', function() -- Incorrect behaviour - -- FIXME should return 0 - null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1) - -- FIXME should return 0 - null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1) - -- FIXME should return 0 - null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1) -- FIXME should not error out null_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') -- FIXME should not error out @@ -129,6 +123,9 @@ describe('NULL', function() '', '\n', function() eq({''}, curbufmeths.get_lines(0, -1, false)) end) + null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0) + null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, 0) + null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, 0) end) describe('dict', function() it('does not crash when indexing NULL dict', function() -- cgit From 83f77c80c084a0390b5a6efd364b33620c9f3d10 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:33:05 +0300 Subject: quickfix: Fix :cexpr and :lexpr --- test/functional/eval/null_spec.lua | 11 +++-------- 1 file changed, 3 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 30c6d3d450..3f3217649b 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -40,14 +40,6 @@ describe('NULL', function() end) end describe('list', function() - -- Incorrect behaviour - - -- FIXME should not error out - null_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected') - -- FIXME should not error out - 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 @@ -58,6 +50,7 @@ describe('NULL', function() null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) -- Correct behaviour + null_test('is accepted by :for', 'for x in L|throw x|endfor', 0) null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() eq({''}, curbufmeths.get_lines(0, -1, false)) end) @@ -126,6 +119,8 @@ describe('NULL', function() null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0) null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, 0) 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) end) describe('dict', function() it('does not crash when indexing NULL dict', function() -- cgit From 0b03ac2cb2399a850bb71d8c0a76d0893bf503cb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:34:32 +0300 Subject: functests: Mark islocked("v:_null_list") behaviour correct It is the same for other VAR_FIXED lists. --- 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 3f3217649b..1c1dd6fd79 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -46,10 +46,9 @@ describe('NULL', function() null_expr_test('is equal to empty list', 'L == []', 0, 0) -- FIXME Should return 1 null_expr_test('is equal to empty list (reverse order)', '[] == L', 0, 0) - -- FIXME Should return 1 - null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) -- Correct behaviour + null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) null_test('is accepted by :for', 'for x in L|throw x|endfor', 0) null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() eq({''}, curbufmeths.get_lines(0, -1, false)) -- cgit From d11884db497114bc8ac5e33964ed81165f8a50fe Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 23:02:19 +0300 Subject: eval: Fix uniq() crash in legacy test 055 --- test/functional/eval/null_spec.lua | 2 ++ 1 file changed, 2 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 1c1dd6fd79..64be8fcd11 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -102,6 +102,8 @@ describe('NULL', function() 'E742: Cannot change value of reverse() argument', 0) null_expr_test('makes sort() error out', 'sort(L)', 'E742: Cannot change value of sort() argument', 0) + null_expr_test('makes uniq() error out', 'uniq(L)', + 'E742: Cannot change value of uniq() argument', 0) 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}) null_expr_test('makes join() return empty string', 'join(L, "")', 0, '') -- cgit From 622d355ab46b4d9282de9db6f25701882dd8f4ab Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 23:16:00 +0300 Subject: functests: Add some more NULL tests --- test/functional/eval/null_spec.lua | 8 ++++++++ 1 file changed, 8 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 64be8fcd11..14b2d964d5 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -40,6 +40,11 @@ describe('NULL', function() end) end describe('list', function() + -- Incorrect behaviour + -- FIXME Should error out with different message + null_test('makes :unlet act as if it is not a list', ':unlet L[0]', + 'Vim(unlet):E689: Can only index a List or Dictionary') + -- Subjectable behaviour -- FIXME Should return 1 @@ -48,6 +53,9 @@ describe('NULL', function() null_expr_test('is equal to empty list (reverse order)', '[] == L', 0, 0) -- Correct behaviour + null_expr_test('can be indexed with error message for empty list', 'L[0]', + 'E684: list index out of range: 0\nE15: Invalid expression: L[0]', nil) + null_expr_test('can be splice-indexed', 'L[:]', 0, {}) null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0) null_test('is accepted by :for', 'for x in L|throw x|endfor', 0) null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function() -- cgit From 1a961b57505f57130012fe4fcfda0e8009c8da45 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 10:34:58 +0300 Subject: eval: Fix add() --- test/functional/eval/null_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 14b2d964d5..afe999e1fa 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -101,7 +101,8 @@ describe('NULL', function() null_expr_test('is accepted as an empty list by writefile()', ('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname), 0, {0, {}}) - null_expr_test('does not crash add()', 'add(L, 0)', 0, 1) + null_expr_test('makes add() error out', 'add(L, 0)', + 'E742: Cannot change value of add() argument', 1) null_expr_test('makes insert() error out', 'insert(L, 1)', 'E742: Cannot change value of insert() argument', 0) null_expr_test('does not crash remove()', 'remove(L, 0)', -- cgit