annotate src/testdir/test_filter_cmd.vim @ 34748:529709e74c11 v9.1.0252

patch 9.1.0252: Vim9: segfault with static in super class Commit: https://github.com/vim/vim/commit/2ed5a11b1a84c86b5392110a81302ae038b5c554 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Apr 1 14:50:41 2024 +0200 patch 9.1.0252: Vim9: segfault with static in super class Problem: Vim9: segfault with static in super class (Ernie Rael) Solution: When initializing lhs, use the correct class where a class variable is defined (Yegappan Lakshmanan) fixes: #14352 closes: #14372 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Apr 2024 15:00:09 +0200
parents fa7ac1e66026
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test the :filter command modifier
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18454
diff changeset
3 source check.vim
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18454
diff changeset
4
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_filter()
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 edit Xdoesnotmatch
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 edit Xwillmatch
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call assert_equal('"Xwillmatch"', substitute(execute('filter willma ls'), '[^"]*\(".*"\)[^"]*', '\1', ''))
9980
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
9 bwipe Xdoesnotmatch
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
10 bwipe Xwillmatch
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
11
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
12 new
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
13 call setline(1, ['foo1', 'foo2', 'foo3', 'foo4', 'foo5'])
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
14 call assert_equal("\nfoo2\nfoo4", execute('filter /foo[24]/ 1,$print'))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
15 call assert_equal("\n 2 foo2\n 4 foo4", execute('filter /foo[24]/ 1,$number'))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
16 call assert_equal("\nfoo2$\nfoo4$", execute('filter /foo[24]/ 1,$list'))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
17
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
18 call assert_equal("\nfoo1$\nfoo3$\nfoo5$", execute('filter! /foo[24]/ 1,$list'))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
19 bwipe!
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
20
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
21 command XTryThis echo 'this'
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
22 command XTryThat echo 'that'
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
23 command XDoThat echo 'that'
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
24 let lines = split(execute('filter XTry command'), "\n")
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
25 call assert_equal(3, len(lines))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
26 call assert_match("XTryThat", lines[1])
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
27 call assert_match("XTryThis", lines[2])
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
28 delcommand XTryThis
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
29 delcommand XTryThat
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
30 delcommand XDoThat
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
31
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
32 map f1 the first key
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
33 map f2 the second key
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
34 map f3 not a key
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
35 let lines = split(execute('filter the map f'), "\n")
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
36 call assert_equal(2, len(lines))
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
37 call assert_match("f2", lines[0])
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
38 call assert_match("f1", lines[1])
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
39 unmap f1
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
40 unmap f2
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
41 unmap f3
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 endfunc
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 func Test_filter_fails()
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_fails('filter', 'E471:')
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_fails('filter pat', 'E476:')
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_fails('filter /pat', 'E476:')
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_fails('filter /pat/', 'E476:')
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_fails('filter /pat/ asdf', 'E492:')
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
50 " Using assert_fails() causes E476 instead of E866. So use a try-catch.
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
51 let caught_e866 = 0
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
52 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
53 filter /\@>b/ ls
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
54 catch /E866:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
55 let caught_e866 = 1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
56 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
57 call assert_equal(1, caught_e866)
9980
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
58
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
59 call assert_fails('filter!', 'E471:')
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
60 call assert_fails('filter! pat', 'E476:')
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
61 call assert_fails('filter! /pat', 'E476:')
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
62 call assert_fails('filter! /pat/', 'E476:')
b222552cf0c4 commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents: 9941
diff changeset
63 call assert_fails('filter! /pat/ asdf', 'E492:')
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endfunc
10520
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
65
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
66 function s:complete_filter_cmd(filtcmd)
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
67 let keystroke = "\<TAB>\<C-R>=execute('let cmdline = getcmdline()')\<CR>\<C-C>"
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
68 let cmdline = ''
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
69 call feedkeys(':' . a:filtcmd . keystroke, 'ntx')
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
70 return cmdline
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
71 endfunction
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
72
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
73 func Test_filter_cmd_completion()
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
74 " Do not complete pattern
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
75 call assert_equal("filter \t", s:complete_filter_cmd('filter '))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
76 call assert_equal("filter pat\t", s:complete_filter_cmd('filter pat'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
77 call assert_equal("filter /pat\t", s:complete_filter_cmd('filter /pat'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
78 call assert_equal("filter /pat/\t", s:complete_filter_cmd('filter /pat/'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
79
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
80 " Complete after string pattern
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
81 call assert_equal('filter pat print', s:complete_filter_cmd('filter pat pri'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
82
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
83 " Complete after regexp pattern
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
84 call assert_equal('filter /pat/ print', s:complete_filter_cmd('filter /pat/ pri'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
85 call assert_equal('filter #pat# print', s:complete_filter_cmd('filter #pat# pri'))
4b152b5f414f commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
86 endfunc
14913
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
87
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
88 func Test_filter_cmd_with_filter()
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
89 new
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
90 set shelltemp
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
91 %!echo "a|b"
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
92 let out = getline(1)
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
93 bw!
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
94 if has('win32')
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
95 let out = trim(out, '" ')
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
96 endif
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
97 call assert_equal('a|b', out)
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
98 set shelltemp&
d4777be849d0 patch 8.1.0468: MS-Windows: filter command with pipe character fails
Bram Moolenaar <Bram@vim.org>
parents: 10520
diff changeset
99 endfunction
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
100
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
101 func Test_filter_commands()
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18454
diff changeset
102 CheckFeature quickfix
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18454
diff changeset
103
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
104 let g:test_filter_a = 1
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
105 let b:test_filter_b = 2
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
106 let test_filter_c = 3
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
107
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
108 " Test filtering :let command
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
109 let res = split(execute("filter /^test_filter/ let"), "\n")
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
110 call assert_equal(["test_filter_a #1"], res)
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
111
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
112 let res = split(execute("filter /\\v^(b:)?test_filter/ let"), "\n")
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
113 call assert_equal(["test_filter_a #1", "b:test_filter_b #2"], res)
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
114
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
115 unlet g:test_filter_a
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
116 unlet b:test_filter_b
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
117 unlet test_filter_c
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
118
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
119 " Test filtering :set command
14987
5b06b642fbee patch 8.1.0505: filter command test may fail if helplang is not set
Bram Moolenaar <Bram@vim.org>
parents: 14968
diff changeset
120 let helplang=&helplang
5b06b642fbee patch 8.1.0505: filter command test may fail if helplang is not set
Bram Moolenaar <Bram@vim.org>
parents: 14968
diff changeset
121 set helplang=en
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
122 let res = join(split(execute("filter /^help/ set"), "\n")[1:], " ")
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
123 call assert_match('^\s*helplang=\w*$', res)
14987
5b06b642fbee patch 8.1.0505: filter command test may fail if helplang is not set
Bram Moolenaar <Bram@vim.org>
parents: 14968
diff changeset
124 let &helplang=helplang
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
125
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
126 " Test filtering :llist command
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
127 call setloclist(0, [{"filename": "/path/vim.c"}, {"filename": "/path/vim.h"}, {"module": "Main.Test"}])
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
128 let res = split(execute("filter /\\.c$/ llist"), "\n")
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
129 call assert_equal([" 1 /path/vim.c: "], res)
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
130
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
131 let res = split(execute("filter /\\.Test$/ llist"), "\n")
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
132 call assert_equal([" 3 Main.Test: "], res)
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
133
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
134 " Test filtering :jump command
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
135 e file.c
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
136 e file.h
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
137 e file.hs
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
138 let res = split(execute("filter /\.c$/ jumps"), "\n")[1:]
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
139 call assert_equal([" 2 1 0 file.c", ">"], res)
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
140
16433
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
141 " Test filtering :marks command
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
142 b file.c
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
143 mark A
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
144 b file.h
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
145 mark B
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
146 let res = split(execute("filter /\.c$/ marks"), "\n")[1:]
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
147 call assert_equal([" A 1 0 file.c"], res)
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
148
21091
f6eb0c468ae4 patch 8.2.1097: highlight code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
149 " Test filtering :highlight command
f6eb0c468ae4 patch 8.2.1097: highlight code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
150 highlight MyHlGroup ctermfg=10
f6eb0c468ae4 patch 8.2.1097: highlight code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
151 let res = split(execute("filter /MyHlGroup/ highlight"), "\n")
f6eb0c468ae4 patch 8.2.1097: highlight code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
152 call assert_equal(["MyHlGroup xxx ctermfg=10"], res)
f6eb0c468ae4 patch 8.2.1097: highlight code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
153
16433
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
154 call setline(1, ['one', 'two', 'three'])
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
155 1mark a
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
156 2mark b
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
157 3mark c
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
158 let res = split(execute("filter /two/ marks abc"), "\n")[1:]
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
159 call assert_equal([" b 2 0 two"], res)
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
160
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
161 bwipe! file.c
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
162 bwipe! file.h
9c206a78ec04 patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents: 14987
diff changeset
163 bwipe! file.hs
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14913
diff changeset
164 endfunc
18454
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
165
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
166 func Test_filter_display()
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
167 edit Xdoesnotmatch
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
168 let @a = '!!willmatch'
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
169 let @b = '!!doesnotmatch'
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
170 let @c = "oneline\ntwoline\nwillmatch\n"
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
171 let @/ = '!!doesnotmatch'
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
172 call feedkeys(":echo '!!doesnotmatch:'\<CR>", 'ntx')
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
173 let lines = map(split(execute('filter /willmatch/ display'), "\n"), 'v:val[5:6]')
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
174
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
175 call assert_true(index(lines, '"a') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
176 call assert_false(index(lines, '"b') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
177 call assert_true(index(lines, '"c') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
178 call assert_false(index(lines, '"/') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
179 call assert_false(index(lines, '":') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
180 call assert_false(index(lines, '"%') >= 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
181
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
182 let lines = map(split(execute('filter /doesnotmatch/ display'), "\n"), 'v:val[5:6]')
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
183 call assert_true(index(lines, '"a') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
184 call assert_false(index(lines, '"b') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
185 call assert_true(index(lines, '"c') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
186 call assert_false(index(lines, '"/') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
187 call assert_false(index(lines, '":') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
188 call assert_false(index(lines, '"%') < 0)
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
189
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
190 bwipe!
b912277e3877 patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents: 16433
diff changeset
191 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21091
diff changeset
192
27619
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
193 func Test_filter_scriptnames()
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
194 let lines = split(execute('filter /test_filter_cmd/ scriptnames'), "\n")
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
195 call assert_equal(1, len(lines))
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
196 call assert_match('filter_cmd', lines[0])
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
197 endfunc
fa7ac1e66026 patch 8.2.4336: using :filter for :scriptnames does not work
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
198
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21091
diff changeset
199 " vim: shiftwidth=2 sts=2 expandtab