view src/testdir/test95.in @ 4535:45f97c349537 v7.3.1015

updated for version 7.3.1015 Problem: New regexp engine: Matching composing characters is wrong. Solution: Fix matching composing characters.
author Bram Moolenaar <bram@vim.org>
date Sat, 25 May 2013 14:42:03 +0200
parents 432a6b8c7d93
children f7944ce459ac
line wrap: on
line source

Test for regexp patterns with multi-byte support, using utf-8.
See test64 for the non-multi-byte tests.

A pattern that gives the expected result produces OK, so that we know it was
actually tried.

STARTTEST
:so small.vim
:so mbyte.vim
:set nocp encoding=utf-8 viminfo+=nviminfo nomore
:" tl is a List of Lists with:
:"    regexp pattern
:"    text to test the pattern on
:"    expected match (optional)
:"    expected submatch 1 (optional)
:"    expected submatch 2 (optional)
:"    etc.
:"  When there is no match use only the first two items.
:let tl = []

:"""" Multi-byte character tests. These will fail unless vim is compiled
:"""" with Multibyte (FEAT_MBYTE) or BIG/HUGE features.
:call add(tl, ['[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna'])
:call add(tl, ['[[=a=]]\+', 'ddaãâbcd', 'aãâ'])								" equivalence classes
:call add(tl, ['[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos'])
:call add(tl, [' [^ ]\+', 'start มabcdม ', ' มabcdม'])
:call add(tl, ['[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna'])

:" this is not a normal "i" but 0xec
:call add(tl, ['\p\+', 'ìa', 'ìa'])

:"""" Test recognition of some character classes
:call add(tl, ['\i\+', '&*¨xx ', 'xx'])
:call add(tl, ['\%#=1\i\+', '&*¨xx ', 'xx'])
:call add(tl, ['\f\+', '&*Ÿfname ', 'fname'])
:call add(tl, ['\%#=1\f\+', '&*Ÿfname ', 'fname'])

:"""" Test composing character matching
:call add(tl, ['.ม', 'xม่x yมy', 'yม'])
:call add(tl, ['.ม่', 'xม่x yมy', 'xม่'])
:call add(tl, ["\u05b9", " x\u05b9 ", "x\u05b9"])
:call add(tl, [".\u05b9", " x\u05b9 ", "x\u05b9"])
:call add(tl, ["\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
:call add(tl, [".\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
:call add(tl, ["\u05bb\u05b9", " x\u05b9\u05bb "])
:call add(tl, [".\u05bb\u05b9", " x\u05b9\u05bb "])
:call add(tl, ["\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"])
:call add(tl, [".\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"])


:"""" Test \Z
:call add(tl, ['ú\Z', 'x'])
:call add(tl, ['יהוה\Z', 'יהוה', 'יהוה'])
:call add(tl, ['יְהוָה\Z', 'יהוה', 'יהוה'])
:call add(tl, ['יהוה\Z', 'יְהוָה', 'יְהוָה'])
:call add(tl, ['יְהוָה\Z', 'יְהוָה', 'יְהוָה'])
:call add(tl, ['יְ\Z', 'וְיַ', 'יַ'])
:call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
:call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200dxy", "ק\u200dx"])
:call add(tl, ["ק\u200dx\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
:call add(tl, ["ק\u200dx\\Z", "xק\u200dxy", "ק\u200dx"])
:call add(tl, ["\u05b9\\+\\Z", "xyz", "xyz"])
:call add(tl, ["\\Z\u05b9\\+", "xyz", "xyz"])

:"""" Combining different tests and features
:call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd'])

:"""" Run the tests
:"
:for t in tl
:  let l = matchlist(t[1], t[0])
:" check the match itself
:  if len(l) == 0 && len(t) > 2
:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
:  elseif len(l) > 0 && len(t) == 2
:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
:  elseif len(t) > 2 && l[0] != t[2]
:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
:  else
:    $put ='OK - ' . t[0]
:  endif
:  if len(l) > 0
:"   check all the nine submatches
:    for i in range(1, 9)
:      if len(t) <= i + 2
:        let e = ''
:      else
:        let e = t[i + 2]
:      endif
:      if l[i] != e
:        $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
:      endif
:    endfor
:    unlet i
:  endif
:endfor
:unlet t tl e l

:/\%#=1^Results/,$wq! test.out
ENDTEST

Results of test95: