annotate src/testdir/test_farsi.vim @ 9399:43b8570abbec v7.4.1981

commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 2 18:25:34 2016 +0200 patch 7.4.1981 Problem: No testing for Farsi code. Solution: Add a minimal test. Clean up Farsi code.
author Christian Brabandt <cb@256bit.org>
date Sat, 02 Jul 2016 18:30:05 +0200
parents
children 265268ea1adc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9399
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Simplistic testing of Farsi mode.
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('farsi')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Farsi uses a single byte encoding.
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 set enc=latin1
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 func Test_farsi_toggle()
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 new
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 set altkeymap
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(0, &fkmap)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal(0, &rl)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call feedkeys("\<F8>", 'x')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal(1, &fkmap)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal(1, &rl)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call feedkeys("\<F8>", 'x')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(0, &fkmap)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(0, &rl)
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 set rl
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 " conversion from Farsi 3342 to Farsi VIM.
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call feedkeys("\<F9>", 'x')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let exp = [0xfc, 0xf8, 0xc1, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 \ 0xc8, 0xc9, 0xca, 0xd0, 0xd1, 0xd2, 0xd3, 0xd6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 \ 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd9, 0xda,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 \ 0xdb, 0xdc, 0xdc, 0xc1, 0xdd, 0xde, 0xe0, 0xe0,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 \ 0xe1, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 \ 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 \ 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 \ 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 \ 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 \ 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 \ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 \ 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 \ 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 \ 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xfb, 0xfb, 0xfe,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 \ 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 \ 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xe1,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 \ ]
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " conversion from Farsi VIM to Farsi 3342.
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call feedkeys("\<F9>", 'x')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let exp = [0xfc, 0xf8, 0xc1, 0x83, 0x84, 0x85, 0x86, 0x87,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 \ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x90,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 \ 0x90, 0x90, 0x92, 0x93, 0x93, 0x95, 0x96, 0x97,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 \ 0x98, 0xdc, 0x9a, 0x9b, 0x9c, 0x9e, 0x9e, 0xff,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 \ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 \ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 \ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 \ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 \ 0xc0, 0xc1, 0xc2, 0x83, 0x84, 0x85, 0x86, 0x87,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 \ 0x88, 0x89, 0x8a, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 \ 0x8b, 0x8c, 0x8d, 0x8e, 0xd4, 0xd5, 0x90, 0x93,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 \ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0xdf,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 \ 0x9d, 0xff, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 \ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xec, 0xee, 0xef,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 \ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 \ 0xf8, 0xf9, 0xfa, 0xec, 0x80, 0xfd, 0xee, 0xff,
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 \ ]
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 bwipe!
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 endfunc
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 func Test_farsi_map()
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 new
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 set altkeymap
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 set rl
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 " RHS of mapping is reversed.
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 imap xyz abc
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call feedkeys("axyz\<Esc>", 'tx')
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call assert_equal('cba', getline(1))
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 set norl
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 iunmap xyz
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 set noaltkeymap
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 bwipe!
43b8570abbec commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endfunc