annotate src/testdir/test_spellrare.vim @ 35848:2156e8b7e7d4 v9.1.0642

patch 9.1.0642: Check that mapping rhs starts with lhs fails if not simplified Commit: https://github.com/vim/vim/commit/9d997addc7bd0fd132a809cf497ed816e61fcd25 Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Jul 29 21:10:07 2024 +0200 patch 9.1.0642: Check that mapping rhs starts with lhs fails if not simplified Problem: Check that mapping rhs starts with lhs doesn't work if lhs is not simplified. Solution: Keep track of the mapblock containing the alternative lhs and also compare with it (zeertzjq). fixes: #15376 closes: #15384 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 29 Jul 2024 21:15:05 +0200
parents a786d0dab454
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35197
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test spell checking
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 source check.vim
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 CheckFeature spell
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Test spellbadword() with argument, specifically to move to "rare" words
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " in normal mode.
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_spellrareword()
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 set spell
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " Create a small word list to test that spellbadword('...')
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " can return ['...', 'rare'].
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 let lines =<< trim END
35202
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
14 foo
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
15 foobar/?
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
16 foobara/?
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
17 END
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
18 call writefile(lines, 'Xwords', 'D')
35197
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
35202
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
20 mkspell! Xwords.spl Xwords
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
21 set spelllang=Xwords.spl
a786d0dab454 patch 9.1.0419: eval.c not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 35197
diff changeset
22 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
35197
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 new
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call setline(1, ['foo', '', 'foo bar foo bar foobara foo foo foo foobar', '', 'End'])
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 set spell wrapscan
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 normal ]s
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_equal('foo', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 normal ]s
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_equal('bar', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 normal ]r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal('foobara', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 normal ]r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal('foobar', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 normal ]r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal('foobara', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 normal 2]r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal('foobara', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 normal [r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call assert_equal('foobar', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 normal [r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal('foobara', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 normal [r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal('foobar', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 normal 2[r
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal('foobar', expand('<cword>'))
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 bwipe!
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 set nospell
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call delete('Xwords.spl')
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 set spelllang&
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 set spell&
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " set 'encoding' to clear the word list
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 set encoding=utf-8
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 endfunc
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
ffa6ed03a9f2 patch 9.1.0418: Cannot move to previous/next rare word
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " vim: shiftwidth=2 sts=2 expandtab