Skip to content

Commit b5e8377

Browse files
committed
patch 8.0.0385: no tests for arabic
Problem: No tests for arabic. Solution: Add a first test for arabic. (Dominique Pelle, closes #1518)
1 parent d512e17 commit b5e8377

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,7 @@ test1 \
20922092

20932093
# Run individual NEW style test, assuming that Vim was already compiled.
20942094
test_arglist \
2095+
test_arabic \
20952096
test_assert \
20962097
test_assign \
20972098
test_autochdir \

src/testdir/Make_all.mak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ SCRIPTS_GUI =
133133

134134
# Tests using runtest.vim.vim.
135135
# Keep test_alot*.res as the last one, sort the others.
136-
NEW_TESTS = test_arglist.res \
136+
NEW_TESTS = test_arabic.res \
137+
test_arglist.res \
137138
test_assert.res \
138139
test_autochdir.res \
139140
test_backspace_opt.res \

src/testdir/test_arabic.vim

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
" Simplistic testing of Arabic mode.
2+
3+
if !has('arabic')
4+
finish
5+
endif
6+
7+
set encoding=utf-8
8+
scriptencoding utf-8
9+
10+
" Return list of utf8 sequences of each character at line lnum.
11+
" Combining characters are treated as a single item.
12+
func GetCharsUtf8(lnum)
13+
call cursor(a:lnum, 1)
14+
let chars = []
15+
let numchars = strchars(getline('.'), 1)
16+
for i in range(1, numchars)
17+
exe 'norm ' i . '|'
18+
call add(chars, execute('norm g8'))
19+
endfor
20+
return chars
21+
endfunc
22+
23+
func Test_arabic_toggle()
24+
set arabic
25+
call assert_equal(1, &rightleft)
26+
call assert_equal(1, &arabicshape)
27+
call assert_equal('arabic', &keymap)
28+
call assert_equal(1, &delcombine)
29+
30+
set iminsert=1 imsearch=1
31+
set arabic&
32+
call assert_equal(0, &rightleft)
33+
call assert_equal(1, &arabicshape)
34+
call assert_equal('arabic', &keymap)
35+
call assert_equal(1, &delcombine)
36+
call assert_equal(0, &iminsert)
37+
call assert_equal(-1, &imsearch)
38+
39+
set arabicshape& keymap= delcombine&
40+
endfunc
41+
42+
func Test_arabic_input()
43+
new
44+
set arabic
45+
" Typing sghl in Arabic insert mode should show the
46+
" Arabic word 'Salaam' i.e. 'peace'.
47+
call feedkeys('isghl', 'tx')
48+
redraw
49+
call assert_equal([
50+
\ "\nd8 b3 ",
51+
\ "\nd9 84 + d8 a7 ",
52+
\ "\nd9 85 "], GetCharsUtf8(1))
53+
54+
" Without shaping, it should give individual Arabic letters.
55+
set noarabicshape
56+
redraw
57+
call assert_equal([
58+
\ "\nd8 b3 ",
59+
\ "\nd9 84 ",
60+
\ "\nd8 a7 ",
61+
\ "\nd9 85 "], GetCharsUtf8(1))
62+
63+
set arabicshape&
64+
set arabic&
65+
bwipe!
66+
endfunc
67+
68+
func Test_arabic_toggle_keymap()
69+
new
70+
set arabic
71+
call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
72+
redraw
73+
call assert_equal('١٢12١٢', getline('.'))
74+
set arabic&
75+
bwipe!
76+
endfunc
77+
78+
func Test_delcombine()
79+
new
80+
set arabic
81+
call feedkeys("isghl\<BS>\<BS>", 'tx')
82+
redraw
83+
call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1))
84+
85+
" Now the same with nodelcombine
86+
set nodelcombine
87+
%d
88+
call feedkeys("isghl\<BS>\<BS>", 'tx')
89+
call assert_equal(["\nd8 b3 "], GetCharsUtf8(1))
90+
set arabic&
91+
bwipe!
92+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
385,
767769
/**/
768770
384,
769771
/**/

0 commit comments

Comments
 (0)