annotate src/testdir/test63.in @ 2233:43cad213cb7f vim73

A bit of cleanup and simplification for undofile.
author Bram Moolenaar <bram@vim.org>
date Sun, 30 May 2010 16:01:37 +0200
parents b63792dadc23
children f9fa2e506b9f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1326
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
1 Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
2 "matchadd()", "matcharg()", "matchdelete()", and "setmatches()".
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
4 STARTTEST
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
5 :so small.vim
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
6 :" --- Check that "matcharg()" returns the correct group and pattern if a match
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
7 :" --- is defined.
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
8 :let @r = "*** Test 1: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
9 :highlight MyGroup1 ctermbg=red
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
10 :highlight MyGroup2 ctermbg=green
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
11 :highlight MyGroup3 ctermbg=blue
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
12 :match MyGroup1 /TODO/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
13 :2match MyGroup2 /FIXME/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
14 :3match MyGroup3 /XXX/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
15 :if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2', 'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
16 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
17 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
18 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
19 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
20 :" --- Check that "matcharg()" returns an empty list if the argument is not 1,
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
21 :" --- 2 or 3 (only 0 and 4 are tested).
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
22 :let @r .= "*** Test 2: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
23 :if matcharg(0) == [] && matcharg(4) == []
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
24 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
25 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
26 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
27 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
28 :" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
29 :let @r .= "*** Test 3: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
30 :match
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
31 :2match
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
32 :3match
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
33 :if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['', '']
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
34 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
35 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
36 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
37 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
38 :" --- Check that "matchadd()" and "getmatches()" agree on added matches and
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
39 :" --- that default values apply.
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
40 :let @r .= "*** Test 4: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
41 :let m1 = matchadd("MyGroup1", "TODO")
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
42 :let m2 = matchadd("MyGroup2", "FIXME", 42)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
43 :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
44 :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5}, {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
45 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
46 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
47 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
48 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
49 :" --- Check that "matchdelete()" deletes the matches defined in the previous
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
50 :" --- test correctly.
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
51 :let @r .= "*** Test 5: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
52 :call matchdelete(m1)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
53 :call matchdelete(m2)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
54 :call matchdelete(m3)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
55 :unlet m1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
56 :unlet m2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
57 :unlet m3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
58 :if getmatches() == []
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
59 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
60 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
61 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
62 :endif
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1326
diff changeset
63 :" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
1326
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
64 :let @r .= "*** Test 6: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
65 :let m = matchadd("MyGroup1", "TODO")
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
66 :let r1 = matchdelete(m)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
67 :let r2 = matchdelete(42)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
68 :if r1 == 0 && r2 == -1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
69 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
70 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
71 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
72 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
73 :unlet m
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
74 :unlet r1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
75 :unlet r2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
76 :" --- Check that "clearmatches()" clears all matches defined by ":match" and
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
77 :" --- "matchadd()".
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
78 :let @r .= "*** Test 7: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
79 :let m1 = matchadd("MyGroup1", "TODO")
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
80 :let m2 = matchadd("MyGroup2", "FIXME", 42)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
81 :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
82 :match MyGroup1 /COFFEE/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
83 :2match MyGroup2 /HUMPPA/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
84 :3match MyGroup3 /VIM/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
85 :call clearmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
86 :if getmatches() == []
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
87 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
88 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
89 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
90 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
91 :unlet m1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
92 :unlet m2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
93 :unlet m3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
94 :" --- Check that "setmatches()" restores a list of matches saved by
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
95 :" --- "getmatches()" without changes. (Matches with equal priority must also
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
96 :" --- remain in the same order.)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
97 :let @r .= "*** Test 8: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
98 :let m1 = matchadd("MyGroup1", "TODO")
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
99 :let m2 = matchadd("MyGroup2", "FIXME", 42)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
100 :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
101 :match MyGroup1 /COFFEE/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
102 :2match MyGroup2 /HUMPPA/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
103 :3match MyGroup3 /VIM/
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
104 :let ml = getmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
105 :call clearmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
106 :call setmatches(ml)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
107 :if getmatches() == ml
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
108 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
109 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
110 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
111 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
112 :call clearmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
113 :unlet m1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
114 :unlet m2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
115 :unlet m3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
116 :unlet ml
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
117 :" --- Check that "setmatches()" will not add two matches with the same ID. The
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
118 :" --- expected behaviour (for now) is to add the first match but not the
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
119 :" --- second and to return 0 (even though it is a matter of debate whether
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1326
diff changeset
120 :" --- this can be considered successful behaviour).
1326
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
121 :let @r .= "*** Test 9: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
122 :let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
123 :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}] && r1 == 0
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
124 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
125 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
126 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
127 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
128 :call clearmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
129 :unlet r1
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1326
diff changeset
130 :" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
1326
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
131 :" --- (A range of valid and invalid input values are tried out to generate the
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
132 :" --- return values.)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
133 :let @r .= "*** Test 10: "
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
134 :let rs1 = setmatches([])
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
135 :let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
136 :call clearmatches()
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
137 :let rf1 = setmatches(0)
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
138 :let rf2 = setmatches([0])
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
139 :let rf3 = setmatches([{'wrong key': 'wrong value'}])
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
140 :if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
141 : let @r .= "OK\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
142 :else
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
143 : let @r .= "FAILED\n"
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
144 :endif
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
145 :unlet rs1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
146 :unlet rs2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
147 :unlet rf1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
148 :unlet rf2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
149 :unlet rf3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
150 :highlight clear MyGroup1
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
151 :highlight clear MyGroup2
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
152 :highlight clear MyGroup3
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
153 G"rp
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
154 :/^Results/,$wq! test.out
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
155 ENDTEST
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
156
22886f3d882d updated for version 7.1-040
vimboss
parents: 1325
diff changeset
157 Results of test63: