Skip to content

Commit 3ff2f09

Browse files
committed
patch 8.0.0497: arabic support is not fully tested
Problem: Arabic support is not fully tested. Solution: Add more tests for the untested functions. Comment out unreachable code.
1 parent 518c9b1 commit 3ff2f09

3 files changed

Lines changed: 154 additions & 1 deletion

File tree

src/arabic.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ static int chg_c_a2s(int cur_c);
2424
static int chg_c_a2i(int cur_c);
2525
static int chg_c_a2m(int cur_c);
2626
static int chg_c_a2f(int cur_c);
27+
#if 0
2728
static int chg_c_i2m(int cur_c);
29+
#endif
2830
static int chg_c_f2m(int cur_c);
2931
static int chg_c_laa2i(int hid_c);
3032
static int chg_c_laa2f(int hid_c);
@@ -418,7 +420,10 @@ chg_c_a2f(int cur_c)
418420

419421
/*
420422
* Change shape - from Initial to Medial
423+
* This code is unreachable, because for the relevant characters ARABIC_CHAR()
424+
* is FALSE;
421425
*/
426+
#if 0
422427
static int
423428
chg_c_i2m(int cur_c)
424429
{
@@ -450,6 +455,7 @@ chg_c_i2m(int cur_c)
450455
}
451456
return 0;
452457
}
458+
#endif
453459

454460

455461
/*
@@ -608,7 +614,11 @@ arabic_shape(
608614
else if (!shape_c || A_is_f(shape_c) || A_is_s(shape_c) || prev_laa)
609615
curr_c = A_is_valid(next_c) ? chg_c_a2i(c) : chg_c_a2s(c);
610616
else if (A_is_valid(next_c))
617+
#if 0
611618
curr_c = A_is_iso(c) ? chg_c_a2m(c) : chg_c_i2m(c);
619+
#else
620+
curr_c = A_is_iso(c) ? chg_c_a2m(c) : 0;
621+
#endif
612622
else if (A_is_valid(prev_c))
613623
curr_c = chg_c_a2f(c);
614624
else

src/testdir/test_arabic.vim

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
" Simplistic testing of Arabic mode.
2+
" NOTE: This just checks if the code works. If you know Arabic please add
3+
" functional tests that check the shaping works with real text.
24

35
if !has('arabic') || !has('multi_byte')
46
finish
@@ -417,7 +419,7 @@ func Test_shape_isolated()
417419
bwipe!
418420
endfunc
419421

420-
func Test_shape_medial()
422+
func Test_shape_iso_to_medial()
421423
new
422424
set arabicshape
423425

@@ -470,3 +472,142 @@ func Test_shape_medial()
470472
bwipe!
471473
endfunc
472474

475+
func Test_shape_final()
476+
new
477+
set arabicshape
478+
479+
" Shaping arabic {testchar} arabic Tests chg_c_a2f().
480+
" pair[0] = testchar, pair[1] = current-result, pair[2] = previous-result
481+
for pair in [[s:a_HAMZA, s:a_s_HAMZA, s:a_s_BEH],
482+
\[s:a_ALEF_MADDA, s:a_f_ALEF_MADDA, s:a_i_BEH],
483+
\[s:a_ALEF_HAMZA_ABOVE, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH],
484+
\[s:a_WAW_HAMZA, s:a_f_WAW_HAMZA, s:a_i_BEH],
485+
\[s:a_ALEF_HAMZA_BELOW, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH],
486+
\[s:a_YEH_HAMZA, s:a_f_YEH_HAMZA, s:a_i_BEH],
487+
\[s:a_ALEF, s:a_f_ALEF, s:a_i_BEH],
488+
\[s:a_BEH, s:a_f_BEH, s:a_i_BEH],
489+
\[s:a_TEH_MARBUTA, s:a_f_TEH_MARBUTA, s:a_i_BEH],
490+
\[s:a_TEH, s:a_f_TEH, s:a_i_BEH],
491+
\[s:a_THEH, s:a_f_THEH, s:a_i_BEH],
492+
\[s:a_JEEM, s:a_f_JEEM, s:a_i_BEH],
493+
\[s:a_HAH, s:a_f_HAH, s:a_i_BEH],
494+
\[s:a_KHAH, s:a_f_KHAH, s:a_i_BEH],
495+
\[s:a_DAL, s:a_f_DAL, s:a_i_BEH],
496+
\[s:a_THAL, s:a_f_THAL, s:a_i_BEH],
497+
\[s:a_REH, s:a_f_REH, s:a_i_BEH],
498+
\[s:a_ZAIN, s:a_f_ZAIN, s:a_i_BEH],
499+
\[s:a_SEEN, s:a_f_SEEN, s:a_i_BEH],
500+
\[s:a_SHEEN, s:a_f_SHEEN, s:a_i_BEH],
501+
\[s:a_SAD, s:a_f_SAD, s:a_i_BEH],
502+
\[s:a_DAD, s:a_f_DAD, s:a_i_BEH],
503+
\[s:a_TAH, s:a_f_TAH, s:a_i_BEH],
504+
\[s:a_ZAH, s:a_f_ZAH, s:a_i_BEH],
505+
\[s:a_AIN, s:a_f_AIN, s:a_i_BEH],
506+
\[s:a_GHAIN, s:a_f_GHAIN, s:a_i_BEH],
507+
\[s:a_TATWEEL, s:a_TATWEEL, s:a_i_BEH],
508+
\[s:a_FEH, s:a_f_FEH, s:a_i_BEH],
509+
\[s:a_QAF, s:a_f_QAF, s:a_i_BEH],
510+
\[s:a_KAF, s:a_f_KAF, s:a_i_BEH],
511+
\[s:a_LAM, s:a_f_LAM, s:a_i_BEH],
512+
\[s:a_MEEM, s:a_f_MEEM, s:a_i_BEH],
513+
\[s:a_NOON, s:a_f_NOON, s:a_i_BEH],
514+
\[s:a_HEH, s:a_f_HEH, s:a_i_BEH],
515+
\[s:a_WAW, s:a_f_WAW, s:a_i_BEH],
516+
\[s:a_ALEF_MAKSURA, s:a_f_ALEF_MAKSURA, s:a_i_BEH],
517+
\[s:a_YEH, s:a_f_YEH, s:a_i_BEH],
518+
\ ]
519+
call setline(1, ' ' . pair[0] . s:a_BEH)
520+
call assert_equal([' ' . pair[1] . pair[2]], ScreenLines(1, 3))
521+
endfor
522+
523+
set arabicshape&
524+
bwipe!
525+
endfunc
526+
527+
func Test_shape_final_to_medial()
528+
new
529+
set arabicshape
530+
531+
" Shaping arabic {testchar} arabic Tests chg_c_f2m().
532+
" This does not test much...
533+
" pair[0] = testchar, pair[1] = current-result
534+
for pair in [[s:a_f_YEH_HAMZA, s:a_f_BEH],
535+
\[s:a_f_WAW_HAMZA, s:a_s_BEH],
536+
\[s:a_f_ALEF, s:a_s_BEH],
537+
\[s:a_f_TEH_MARBUTA, s:a_s_BEH],
538+
\[s:a_f_DAL, s:a_s_BEH],
539+
\[s:a_f_THAL, s:a_s_BEH],
540+
\[s:a_f_REH, s:a_s_BEH],
541+
\[s:a_f_ZAIN, s:a_s_BEH],
542+
\[s:a_f_WAW, s:a_s_BEH],
543+
\[s:a_f_ALEF_MAKSURA, s:a_s_BEH],
544+
\[s:a_f_BEH, s:a_f_BEH],
545+
\[s:a_f_TEH, s:a_f_BEH],
546+
\[s:a_f_THEH, s:a_f_BEH],
547+
\[s:a_f_JEEM, s:a_f_BEH],
548+
\[s:a_f_HAH, s:a_f_BEH],
549+
\[s:a_f_KHAH, s:a_f_BEH],
550+
\[s:a_f_SEEN, s:a_f_BEH],
551+
\[s:a_f_SHEEN, s:a_f_BEH],
552+
\[s:a_f_SAD, s:a_f_BEH],
553+
\[s:a_f_DAD, s:a_f_BEH],
554+
\[s:a_f_TAH, s:a_f_BEH],
555+
\[s:a_f_ZAH, s:a_f_BEH],
556+
\[s:a_f_AIN, s:a_f_BEH],
557+
\[s:a_f_GHAIN, s:a_f_BEH],
558+
\[s:a_f_FEH, s:a_f_BEH],
559+
\[s:a_f_QAF, s:a_f_BEH],
560+
\[s:a_f_KAF, s:a_f_BEH],
561+
\[s:a_f_LAM, s:a_f_BEH],
562+
\[s:a_f_MEEM, s:a_f_BEH],
563+
\[s:a_f_NOON, s:a_f_BEH],
564+
\[s:a_f_HEH, s:a_f_BEH],
565+
\[s:a_f_YEH, s:a_f_BEH],
566+
\ ]
567+
call setline(1, ' ' . s:a_BEH . pair[0])
568+
call assert_equal([' ' . pair[1] . pair[0]], ScreenLines(1, 3))
569+
endfor
570+
571+
set arabicshape&
572+
bwipe!
573+
endfunc
574+
575+
func Test_shape_combination_final()
576+
new
577+
set arabicshape
578+
579+
" Shaping arabic {testchar} arabic Tests chg_c_laa2f().
580+
" pair[0] = testchar, pair[1] = current-result
581+
for pair in [[s:a_ALEF_MADDA, s:a_f_LAM_ALEF_MADDA_ABOVE],
582+
\ [s:a_ALEF_HAMZA_ABOVE, s:a_f_LAM_ALEF_HAMZA_ABOVE],
583+
\ [s:a_ALEF_HAMZA_BELOW, s:a_f_LAM_ALEF_HAMZA_BELOW],
584+
\ [s:a_ALEF, s:a_f_LAM_ALEF],
585+
\ ]
586+
" The test char is a composing char, put on s:a_LAM.
587+
call setline(1, ' ' . s:a_LAM . pair[0] . s:a_BEH)
588+
call assert_equal([' ' . pair[1] . s:a_i_BEH], ScreenLines(1, 3))
589+
endfor
590+
591+
set arabicshape&
592+
bwipe!
593+
endfunc
594+
595+
func Test_shape_combination_isolated()
596+
new
597+
set arabicshape
598+
599+
" Shaping arabic {testchar} arabic Tests chg_c_laa2i().
600+
" pair[0] = testchar, pair[1] = current-result
601+
for pair in [[s:a_ALEF_MADDA, s:a_s_LAM_ALEF_MADDA_ABOVE],
602+
\ [s:a_ALEF_HAMZA_ABOVE, s:a_s_LAM_ALEF_HAMZA_ABOVE],
603+
\ [s:a_ALEF_HAMZA_BELOW, s:a_s_LAM_ALEF_HAMZA_BELOW],
604+
\ [s:a_ALEF, s:a_s_LAM_ALEF],
605+
\ ]
606+
" The test char is a composing char, put on s:a_LAM.
607+
call setline(1, ' ' . s:a_LAM . pair[0] . ' ')
608+
call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3))
609+
endfor
610+
611+
set arabicshape&
612+
bwipe!
613+
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+
497,
767769
/**/
768770
496,
769771
/**/

0 commit comments

Comments
 (0)