neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_glob2regpat.vim (1436B)


      1 " Test glob2regpat()
      2 
      3 source vim9.vim
      4 
      5 func Test_glob2regpat_invalid()
      6  if has('float')
      7    call assert_equal('^1\.33$', glob2regpat(1.33))
      8    call CheckDefExecAndScriptFailure(['echo glob2regpat(1.33)'], 'E806:')
      9  endif
     10  call assert_fails('call glob2regpat("}")', 'E219:')
     11  call assert_fails('call glob2regpat("{")', 'E220:')
     12 endfunc
     13 
     14 func Test_glob2regpat_valid()
     15  call assert_equal('^foo\.', glob2regpat('foo.*'))
     16  call assert_equal('^foo.$', 'foo?'->glob2regpat())
     17  call assert_equal('\.vim$', glob2regpat('*.vim'))
     18  call assert_equal('^[abc]$', glob2regpat('[abc]'))
     19  call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
     20  call assert_equal('^foo,bar$', glob2regpat('foo,bar'))
     21  call assert_equal('^\(foo\|bar\)$', glob2regpat('{foo,bar}'))
     22  call assert_equal('.*', glob2regpat('**'))
     23 
     24  if exists('+shellslash')
     25    call assert_equal('^foo[\/].$', glob2regpat('foo\?'))
     26    call assert_equal('^\(foo[\/]\|bar\|foobar\)$', glob2regpat('{foo\,bar,foobar}'))
     27    call assert_equal('^[\/]\(foo\|bar[\/]\)$', glob2regpat('\{foo,bar\}'))
     28    call assert_equal('^[\/][\/]\(foo\|bar[\/][\/]\)$', glob2regpat('\\{foo,bar\\}'))
     29  else
     30    call assert_equal('^foo?$', glob2regpat('foo\?'))
     31    call assert_equal('^\(foo,bar\|foobar\)$', glob2regpat('{foo\,bar,foobar}'))
     32    call assert_equal('^{foo,bar}$', glob2regpat('\{foo,bar\}'))
     33    call assert_equal('^\\\(foo\|bar\\\)$', glob2regpat('\\{foo,bar\\}'))
     34  endif
     35 endfunc