view src/testdir/test_glob2regpat.vim @ 19249:2a017e9dc6da v8.2.0183

patch 8.2.0183: tests fail when the float feature is disabled Commit: https://github.com/vim/vim/commit/5feabe00c47fa66d5f4c95213f150488433f78e3 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 30 18:24:53 2020 +0100 patch 8.2.0183: tests fail when the float feature is disabled Problem: Tests fail when the float feature is disabled. Solution: Skip tests that don't work without float support.
author Bram Moolenaar <Bram@vim.org>
date Thu, 30 Jan 2020 18:30:04 +0100
parents 9fac6d0de69a
children 08940efa6b4e
line wrap: on
line source

" Test glob2regpat()

func Test_glob2regpat_invalid()
  if has('float')
    call assert_fails('call glob2regpat(1.33)', 'E806:')
  endif
  call assert_fails('call glob2regpat("}")', 'E219:')
  call assert_fails('call glob2regpat("{")', 'E220:')
endfunc

func Test_glob2regpat_valid()
  call assert_equal('^foo\.', glob2regpat('foo.*'))
  call assert_equal('^foo.$', 'foo?'->glob2regpat())
  call assert_equal('\.vim$', glob2regpat('*.vim'))
  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('**'))

  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
    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
endfunc