Patch 8.0.0389
Problem:    Test for arabic does not check what is displayed.
Solution:   Improve what is asserted. (Dominique Pelle, closes #1523)
            Add a first shaping test.
Files:      src/testdir/test_arabic.vim


*** ../vim-8.0.0388/src/testdir/test_arabic.vim 2017-02-27 21:48:06.217790605 
+0100
--- src/testdir/test_arabic.vim 2017-02-28 22:46:44.550375400 +0100
***************
*** 1,21 ****
  " Simplistic testing of Arabic mode.
  
! if !has('arabic')
    finish
  endif
  
! set encoding=utf-8
! scriptencoding utf-8
  
! " Return list of utf8 sequences of each character at line lnum.
  " Combining characters are treated as a single item.
! func GetCharsUtf8(lnum)
    call cursor(a:lnum, 1)
    let chars = []
    let numchars = strchars(getline('.'), 1)
    for i in range(1, numchars)
      exe 'norm ' i . '|'
!     call add(chars, execute('norm g8'))
    endfor
    return chars
  endfunc
--- 1,23 ----
  " Simplistic testing of Arabic mode.
  
! if !has('arabic') || !has('multi_byte')
    finish
  endif
  
! source view_util.vim
  
! " Return list of Unicode characters at line lnum.
  " Combining characters are treated as a single item.
! func s:get_chars(lnum)
    call cursor(a:lnum, 1)
    let chars = []
    let numchars = strchars(getline('.'), 1)
    for i in range(1, numchars)
      exe 'norm ' i . '|'
!     let c=execute('ascii')
!     let c=substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g')
!     let c=substitute(c, ',\s*Octal\s*\d*', '', 'g')
!     call add(chars, c)
    endfor
    return chars
  endfunc
***************
*** 43,67 ****
    new
    set arabic
    " Typing sghl in Arabic insert mode should show the
!   " Arabic word 'Salaam' i.e. 'peace'.
!   call feedkeys('isghl', 'tx')
!   redraw
    call assert_equal([
!   \ "\nd8 b3 ",
!   \ "\nd9 84 + d8 a7 ",
!   \ "\nd9 85 "], GetCharsUtf8(1))
  
    " Without shaping, it should give individual Arabic letters.
    set noarabicshape
!   redraw
    call assert_equal([
!   \ "\nd8 b3 ",
!   \ "\nd9 84 ",
!   \ "\nd8 a7 ",
!   \ "\nd9 85 "], GetCharsUtf8(1))
  
!   set arabicshape&
!   set arabic&
    bwipe!
  endfunc
  
--- 45,72 ----
    new
    set arabic
    " Typing sghl in Arabic insert mode should show the
!   " Arabic word 'Salaam' i.e. 'peace', spelled:
!   " SEEN, LAM, ALEF, MEEM.
!   " See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left
!   call feedkeys('isghl!', 'tx')
!   call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0])
    call assert_equal([
!   \ 'U+0633',
!   \ 'U+0644 U+0627',
!   \ 'U+0645',
!   \ 'U+21'], s:get_chars(1))
  
    " Without shaping, it should give individual Arabic letters.
    set noarabicshape
!   call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, 
&columns)[0])
    call assert_equal([
!   \ 'U+0633',
!   \ 'U+0644',
!   \ 'U+0627',
!   \ 'U+0645',
!   \ 'U+21'], s:get_chars(1))
  
!   set arabic& arabicshape&
    bwipe!
  endfunc
  
***************
*** 69,75 ****
    new
    set arabic
    call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
!   redraw
    call assert_equal('١٢12١٢', getline('.'))
    set arabic&
    bwipe!
--- 74,80 ----
    new
    set arabic
    call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
!   call assert_match("^ *٢١21٢١$", ScreenLines(1, &columns)[0])
    call assert_equal('١٢12١٢', getline('.'))
    set arabic&
    bwipe!
***************
*** 79,92 ****
    new
    set arabic
    call feedkeys("isghl\<BS>\<BS>", 'tx')
!   redraw
!   call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1))
  
!   " Now the same with nodelcombine
    set nodelcombine
    %d
    call feedkeys("isghl\<BS>\<BS>", 'tx')
!   call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) 
    set arabic&
    bwipe!
  endfunc
--- 84,133 ----
    new
    set arabic
    call feedkeys("isghl\<BS>\<BS>", 'tx')
!   call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0])
!   call assert_equal(['U+0633', 'U+0644'], s:get_chars(1))
  
!   " Now the same with 'nodelcombine'
    set nodelcombine
    %d
    call feedkeys("isghl\<BS>\<BS>", 'tx')
!   call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0])
!   call assert_equal(['U+0633'], s:get_chars(1))
    set arabic&
    bwipe!
  endfunc
+ 
+ let s:a_YEH_HAMZA = "\u0626"
+ let s:a_i_YEH_HAMZA = "\ufe8b"
+ 
+ let s:a_HAMZA = "\u0621"
+ let s:a_s_HAMZA = "\ufe80"
+ 
+ let s:a_ALEF_MADDA = "\u0622"
+ let s:a_s_ALEF_MADDA = "\ufe81"
+ 
+ let s:a_ALEF_HAMZA_ABOVE = "\u0623"
+ let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83"
+ 
+ let s:a_GHAIN = "\u063a"
+ let s:a_f_GHAIN = "\ufece"
+ let s:a_s_GHAIN = "\ufecd"
+ 
+ func Test_shape_initial()
+   new
+   set arabicshape
+ 
+   " Shaping arabic {testchar} non-arabic   Uses chg_c_a2i().
+   " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result
+   for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA],
+       \ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA],
+       \ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA],
+       \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE],
+       \ ]
+     call setline(1, s:a_GHAIN . pair[0] . ' ')
+     call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3))
+   endfor
+ 
+   set arabicshape&
+   bwipe!
+ endfunc
*** ../vim-8.0.0388/src/version.c       2017-02-28 21:53:51.279626358 +0100
--- src/version.c       2017-02-28 22:07:20.238106417 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     389,
  /**/

-- 
If you put 7 of the most talented OSS developers in a room for a week
and asked them to fix a bug in a spreadsheet program, in 1 week
you'd have 2 new mail readers and a text-based web browser.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui