2017-03-11 20:31:50 -07:00
|
|
|
" Test glob2regpat()
|
|
|
|
|
2023-06-11 21:48:14 -07:00
|
|
|
source vim9.vim
|
|
|
|
|
2019-05-25 11:47:17 -07:00
|
|
|
func Test_glob2regpat_invalid()
|
2021-05-24 11:43:47 -07:00
|
|
|
if has('float')
|
2023-06-11 21:48:14 -07:00
|
|
|
call assert_equal('^1\.33$', glob2regpat(1.33))
|
|
|
|
call CheckDefExecAndScriptFailure(['echo glob2regpat(1.33)'], 'E806:')
|
2021-05-24 11:43:47 -07:00
|
|
|
endif
|
2017-03-11 20:35:30 -07:00
|
|
|
call assert_fails('call glob2regpat("}")', 'E219:')
|
|
|
|
call assert_fails('call glob2regpat("{")', 'E220:')
|
2017-03-11 20:31:50 -07:00
|
|
|
endfunc
|
|
|
|
|
2019-05-25 11:47:17 -07:00
|
|
|
func Test_glob2regpat_valid()
|
2017-03-11 20:31:50 -07:00
|
|
|
call assert_equal('^foo\.', glob2regpat('foo.*'))
|
2021-08-31 14:41:44 -07:00
|
|
|
call assert_equal('^foo.$', 'foo?'->glob2regpat())
|
2017-03-11 20:31:50 -07:00
|
|
|
call assert_equal('\.vim$', glob2regpat('*.vim'))
|
2017-03-11 20:35:30 -07:00
|
|
|
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
|
|
|
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
|
|
|
call assert_equal('^foo,bar$', glob2regpat('foo,bar'))
|
|
|
|
call assert_equal('^\(foo\|bar\)$', glob2regpat('{foo,bar}'))
|
|
|
|
call assert_equal('.*', glob2regpat('**'))
|
2017-03-11 20:36:34 -07:00
|
|
|
|
2017-03-11 20:39:09 -07:00
|
|
|
if exists('+shellslash')
|
|
|
|
call assert_equal('^foo[\/].$', glob2regpat('foo\?'))
|
|
|
|
call assert_equal('^\(foo[\/]\|bar\|foobar\)$', glob2regpat('{foo\,bar,foobar}'))
|
|
|
|
call assert_equal('^[\/]\(foo\|bar[\/]\)$', glob2regpat('\{foo,bar\}'))
|
|
|
|
call assert_equal('^[\/][\/]\(foo\|bar[\/][\/]\)$', glob2regpat('\\{foo,bar\\}'))
|
|
|
|
else
|
2017-03-11 20:36:34 -07:00
|
|
|
call assert_equal('^foo?$', glob2regpat('foo\?'))
|
|
|
|
call assert_equal('^\(foo,bar\|foobar\)$', glob2regpat('{foo\,bar,foobar}'))
|
|
|
|
call assert_equal('^{foo,bar}$', glob2regpat('\{foo,bar\}'))
|
|
|
|
call assert_equal('^\\\(foo\|bar\\\)$', glob2regpat('\\{foo,bar\\}'))
|
|
|
|
endif
|
2017-03-11 20:31:50 -07:00
|
|
|
endfunc
|