Commits

ZyX_I committed d9a960f

Some globtopat fixes
Added globtopattern test

  • Participants
  • Parent commits 73ddad0

Comments (0)

Files changed (3)

plugin/aurum/cmdutils.vim

                 let g=g[1:]
                 if g[0] is# '/'
                     let g=g[1:]
-                    let r.='\%(\.\*\)\='
+                    let r.='\%(\.\+/\)\='
                 else
                     let r.='\.\*'
                 endif
             endif
             let colinner=matchstr(g, '\v^(\\.|[^\]])+')
             let g=g[len(colinner):]
-            let r.=substitute(colinner, '\v\\([^\^\]\-\\])', '\1', 'g').']'
+            let r.=substitute(colinner, '\v\\([^\^\]\-\\])', '\1', 'g')
         elseif c is# '{'
             let incurl+=1
             let curlit+=[[]]

test/globtopattern.in

+:execute 'source '.fnameescape(g:curtest).'.vim'

test/globtopattern.vim

+execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0'})
+let files=[
+            \'.hgignore',
+            \'aurum-addon-info.txt',
+            \'doc/aurum.txt',
+            \'ftplugin/aurumannotate.vim',
+            \'ftplugin/aurumcommit.vim',
+            \'ftplugin/aurumlog.vim',
+            \'ftplugin/aurumstatus.vim',
+            \'plugin/aurum.vim',
+            \'plugin/aurum/annotate.vim',
+            \'plugin/aurum/bufvars.vim',
+            \'plugin/aurum/cmdutils.vim',
+            \'plugin/aurum/commit.vim',
+            \'plugin/aurum/drivers/mercurial.vim',
+            \'plugin/aurum/log.vim',
+            \'plugin/aurum/record.vim',
+            \'plugin/aurum/repo.vim',
+            \'plugin/aurum/status.vim',
+            \'plugin/aurum/vimdiff.vim',
+            \'python/aurum.py',
+            \'syntax/aurumannotate.vim',
+            \'syntax/aurumlog.vim',
+            \'syntax/aurumstatus.vim',
+            \'test/addmessages.vim',
+            \'test/annotate-buffers.in',
+            \'test/annotate-buffers.ok',
+            \'test/annotate.in',
+            \'test/annotate.ok',
+            \'test/annotatemaps.in',
+            \'test/annotatemaps.ok',
+            \'test/audiffmaps.in',
+            \'test/audiffmaps.ok',
+            \'test/aufilemaps.in',
+            \'test/aufilemaps.ok',
+            \'test/commit.in',
+            \'test/commit.ok',
+            \'test/copyout-postproc.zsh',
+            \'test/createrepo.zsh',
+            \'test/diff.in',
+            \'test/diff.ok',
+            \'test/file.in',
+            \'test/file.ok',
+            \'test/gentests-expand-tmpdir.zsh',
+            \'test/gentests-setuprtp.zsh',
+            \'test/gentests-setuptestrepos.zsh',
+            \'test/gentests-unnormdates.zsh',
+            \'test/log.in',
+            \'test/log.ok',
+            \'test/logmaps.in',
+            \'test/logmaps.ok',
+            \'test/prevmessage.in',
+            \'test/prevmessage.ok',
+            \'test/record.in',
+            \'test/record.ok',
+            \'test/runtime.tar.xz',
+            \'test/stat.in',
+            \'test/stat.ok',
+            \'test/statmaps.in',
+            \'test/statmaps.ok',
+            \'test/testrepo.tar.xz',
+            \'test/update.in',
+            \'test/update.ok',
+            \'test/vimdiff-usewin.in',
+            \'test/vimdiff-usewin.ok',
+            \'test/vimdiff.in',
+            \'test/vimdiff.ok',
+            \'test/vimrc',
+            \'test/{}',
+            \'test/{this',
+            \'test/{this,that}',
+            \'test/}}',
+            \'test/[',
+            \'test/]',
+            \'test/^.vim',
+        \]
+let failfile=curtest.'.fail'
+for [g, r] in [['plugin/*.vim',                    ['plugin/aurum.vim']],
+            \  ['plugin/{*.vim,aurum/{s,v}*.vim}', ['plugin/aurum.vim',
+            \                                       'plugin/aurum/status.vim',
+            \                                       'plugin/aurum/vimdiff.vim',
+            \                                      ]],
+            \  ['plugin/{*.vim,aurum/[sv]*.vim}',  ['plugin/aurum.vim',
+            \                                       'plugin/aurum/status.vim',
+            \                                       'plugin/aurum/vimdiff.vim',
+            \                                      ]],
+            \  ['python/[!a]*.py',                 []],
+            \  ['**.py',                           ['python/aurum.py']],
+            \  ['**/.py',                          []],
+            \  ['**/*.txt',                        ['aurum-addon-info.txt',
+            \                                       'doc/aurum.txt']],
+            \  ['python',                          ['python/aurum.py']],
+            \  ['python/',                         ['python/aurum.py']],
+            \  ['python////',                      ['python/aurum.py']],
+            \  ['test/{*',                         ['test/{}',
+            \                                       'test/{this',
+            \                                       'test/{this,that}']],
+            \  ['test/{*,*',                       ['test/{this,that}']],
+            \  ['test/}}',                         ['test/}}']],
+            \  ['test/[',                          ['test/[']],
+            \  ['test/]',                          ['test/]']],
+            \  ['test/[^u]*',                      ['test/update.in',
+            \                                       'test/update.ok',
+            \                                       'test/^.vim']],
+            \]
+    let p=s:_r.cmdutils.globtopat(g)
+    let rr=filter(copy(files), 'v:val=~#p')
+    if rr !=# r
+        call writefile([g, p, string(r), string(rr)], failfile)
+        echom 'Failed '.g.':'
+        echom 'expected '.join(r).','
+        echom 'but got '.join(rr)
+        echom 'computed pattern: '.p.'.'
+        break
+    endif
+endfor