comparison src/testdir/test_normal.vim @ 17682:3dbff5d37520 v8.1.1838

patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare commit https://github.com/vim/vim/commit/08cc374dabd2a02785129fa1c0100f7745c244ad Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 11 22:51:14 2019 +0200 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare Problem: There is :spellwrong and :spellgood but not :spellrare. Solution: Add :spellrare. (Martin Tournoij, closes https://github.com/vim/vim/issues/4291)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Aug 2019 23:00:07 +0200
parents 827d29c8f7e8
children 131f1d8c5860
comparison
equal deleted inserted replaced
17681:fbdef42903ae 17682:3dbff5d37520
1084 norm! j 1084 norm! j
1085 call assert_equal('52', getline('.')) 1085 call assert_equal('52', getline('.'))
1086 1086
1087 " clean up 1087 " clean up
1088 setl nofoldenable fdm=marker foldlevel=0 1088 setl nofoldenable fdm=marker foldlevel=0
1089 bw!
1090 endfunc
1091
1092 func Test_normal19_z_spell()
1093 if !has("spell") || !has('syntax')
1094 return
1095 endif
1096 new
1097 call append(0, ['1 good', '2 goood', '3 goood'])
1098 set spell spellfile=./Xspellfile.add spelllang=en
1099 let oldlang=v:lang
1100 lang C
1101
1102 " Test for zg
1103 1
1104 norm! ]s
1105 call assert_equal('2 goood', getline('.'))
1106 norm! zg
1107 1
1108 let a=execute('unsilent :norm! ]s')
1109 call assert_equal('1 good', getline('.'))
1110 call assert_equal('search hit BOTTOM, continuing at TOP', a[1:])
1111 let cnt=readfile('./Xspellfile.add')
1112 call assert_equal('goood', cnt[0])
1113
1114 " Test for zw
1115 2
1116 norm! $zw
1117 1
1118 norm! ]s
1119 call assert_equal('2 goood', getline('.'))
1120 let cnt=readfile('./Xspellfile.add')
1121 call assert_equal('#oood', cnt[0])
1122 call assert_equal('goood/!', cnt[1])
1123
1124 " Test for zg in visual mode
1125 let a=execute('unsilent :norm! V$zg')
1126 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
1127 1
1128 norm! ]s
1129 call assert_equal('3 goood', getline('.'))
1130 let cnt=readfile('./Xspellfile.add')
1131 call assert_equal('2 goood', cnt[2])
1132 " Remove "2 good" from spellfile
1133 2
1134 let a=execute('unsilent norm! V$zw')
1135 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
1136 let cnt=readfile('./Xspellfile.add')
1137 call assert_equal('2 goood/!', cnt[3])
1138
1139 " Test for zG
1140 let a=execute('unsilent norm! V$zG')
1141 call assert_match("Word '2 goood' added to .*", a)
1142 let fname=matchstr(a, 'to\s\+\zs\f\+$')
1143 let cnt=readfile(fname)
1144 call assert_equal('2 goood', cnt[0])
1145
1146 " Test for zW
1147 let a=execute('unsilent norm! V$zW')
1148 call assert_match("Word '2 goood' added to .*", a)
1149 let cnt=readfile(fname)
1150 call assert_equal('# goood', cnt[0])
1151 call assert_equal('2 goood/!', cnt[1])
1152
1153 " Test for zuW
1154 let a=execute('unsilent norm! V$zuW')
1155 call assert_match("Word '2 goood' removed from .*", a)
1156 let cnt=readfile(fname)
1157 call assert_equal('# goood', cnt[0])
1158 call assert_equal('# goood/!', cnt[1])
1159
1160 " Test for zuG
1161 let a=execute('unsilent norm! $zG')
1162 call assert_match("Word 'goood' added to .*", a)
1163 let cnt=readfile(fname)
1164 call assert_equal('# goood', cnt[0])
1165 call assert_equal('# goood/!', cnt[1])
1166 call assert_equal('goood', cnt[2])
1167 let a=execute('unsilent norm! $zuG')
1168 let cnt=readfile(fname)
1169 call assert_match("Word 'goood' removed from .*", a)
1170 call assert_equal('# goood', cnt[0])
1171 call assert_equal('# goood/!', cnt[1])
1172 call assert_equal('#oood', cnt[2])
1173 " word not found in wordlist
1174 let a=execute('unsilent norm! V$zuG')
1175 let cnt=readfile(fname)
1176 call assert_match("", a)
1177 call assert_equal('# goood', cnt[0])
1178 call assert_equal('# goood/!', cnt[1])
1179 call assert_equal('#oood', cnt[2])
1180
1181 " Test for zug
1182 call delete('./Xspellfile.add')
1183 2
1184 let a=execute('unsilent norm! $zg')
1185 let cnt=readfile('./Xspellfile.add')
1186 call assert_equal('goood', cnt[0])
1187 let a=execute('unsilent norm! $zug')
1188 call assert_match("Word 'goood' removed from \./Xspellfile.add", a)
1189 let cnt=readfile('./Xspellfile.add')
1190 call assert_equal('#oood', cnt[0])
1191 " word not in wordlist
1192 let a=execute('unsilent norm! V$zug')
1193 call assert_match('', a)
1194 let cnt=readfile('./Xspellfile.add')
1195 call assert_equal('#oood', cnt[0])
1196
1197 " Test for zuw
1198 call delete('./Xspellfile.add')
1199 2
1200 let a=execute('unsilent norm! Vzw')
1201 let cnt=readfile('./Xspellfile.add')
1202 call assert_equal('2 goood/!', cnt[0])
1203 let a=execute('unsilent norm! Vzuw')
1204 call assert_match("Word '2 goood' removed from \./Xspellfile.add", a)
1205 let cnt=readfile('./Xspellfile.add')
1206 call assert_equal('# goood/!', cnt[0])
1207 " word not in wordlist
1208 let a=execute('unsilent norm! $zug')
1209 call assert_match('', a)
1210 let cnt=readfile('./Xspellfile.add')
1211 call assert_equal('# goood/!', cnt[0])
1212
1213 " add second entry to spellfile setting
1214 set spellfile=./Xspellfile.add,./Xspellfile2.add
1215 call delete('./Xspellfile.add')
1216 2
1217 let a=execute('unsilent norm! $2zg')
1218 let cnt=readfile('./Xspellfile2.add')
1219 call assert_match("Word 'goood' added to ./Xspellfile2.add", a)
1220 call assert_equal('goood', cnt[0])
1221
1222 " Test for :spellgood!
1223 let temp = execute(':spe!0/0')
1224 call assert_match('Invalid region', temp)
1225 let spellfile = matchstr(temp, 'Invalid region nr in \zs.*\ze line \d: 0')
1226 call assert_equal(['# goood', '# goood/!', '#oood', '0/0'], readfile(spellfile))
1227 call delete(spellfile)
1228
1229 " clean up
1230 exe "lang" oldlang
1231 call delete("./Xspellfile.add")
1232 call delete("./Xspellfile2.add")
1233 call delete("./Xspellfile.add.spl")
1234 call delete("./Xspellfile2.add.spl")
1235
1236 " zux -> no-op
1237 2
1238 norm! $zux
1239 call assert_equal([], glob('Xspellfile.add',0,1))
1240 call assert_equal([], glob('Xspellfile2.add',0,1))
1241
1242 set spellfile=
1243 bw! 1089 bw!
1244 endfunc 1090 endfunc
1245 1091
1246 func Test_normal20_exmode() 1092 func Test_normal20_exmode()
1247 if !has("unix") 1093 if !has("unix")