Commits

ZyX_I committed 70e3768

test: Moved os-specific fwccompletetests to a separate files

  • Participants
  • Parent commits 993bbbe

Comments (0)

Files changed (8)

test/fwccomplete-os.in

+:let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
+:let g:testfile="plugin/".g:curtest.".vim"
+:source test-redir.vim

test/fwccomplete-os.ok

+>>> messages
+::: Section <Built-in completion functions/path>
+<<< messages

test/fwccomplete.ok

 ::: Section <Built-in completion functions/either>
 ::: Section <Built-in completion functions/first>
 ::: Section <Built-in completion functions/if>
-::: Section <Built-in completion functions/path>
 ::: Section <Different sections/{required}>
 ::: Section <Different sections/{actions}>
 <<< messages

test/fwccompletetests-os.dat

+!complete
+:let s:list=['abc', 'ab-c', 'def-ghi', 'adb']
+:let s:list2=['abc', 'def-b', 'geh']
+:let s:list3=['foo', 'bar', 'baz']
+:let s:dict={'abc': 1, 'adb': 1, 'aef': 1}
+#▶1 Built-in completion functions
+#▶2 path
+:call os.mkdir('FWCdirectory')
+:call os.chdir('FWCdirectory')
+:call os.mkdir('dir')
+:call os.mkdir('.bar')
+:let abcdefghi=os.path.join('abc', 'def', 'ghi')
+:let dirdef   =os.path.join('dir', 'def')
+:let foodef   =os.path.join('foo', 'def')
+:let dirdefghi=os.path.join(dirdef, 'ghi')
+:call writefile([], 'foo', 'b')
+:call os.makedirs(abcdefghi)
+`path w
+  @+
+  abc/ dir/ foo .bar/
+
+  @.
+  .bar/
+
+  @b
+  abc/ .bar/
+
+  @i
+  dir/
+
+  @a/d
+  abc/def/
+
+  @a/d/
+  abc/def/ghi/
+
+  @/h
+  /home/
+# vim: cms=#%s fmr=▶,▲ sw=2 ts=2 sts=2 et

test/fwccompletetests.dat

 
   @a
   =sort(keys(s:dict))
-#▶2 path
-:call os.mkdir('FWCdirectory')
-:call os.chdir('FWCdirectory')
-:call os.mkdir('dir')
-:call os.mkdir('.bar')
-:let abcdefghi=os.path.join('abc', 'def', 'ghi')
-:let dirdef   =os.path.join('dir', 'def')
-:let foodef   =os.path.join('foo', 'def')
-:let dirdefghi=os.path.join(dirdef, 'ghi')
-:call writefile([], 'foo', 'b')
-:call os.makedirs(abcdefghi)
-`path w
-  @+
-  abc/ dir/ foo .bar/
-
-  @.
-  .bar/
-
-  @b
-  abc/ .bar/
-
-  @i
-  dir/
-
-  @a/d
-  abc/def/
-
-  @a/d/
-  abc/def/ghi/
-
-  @/h
-  /home/
 #▶1 Different sections
 #▶2 {required}
 `in list

test/gwine/fwccompletetests-os.dat

+!complete
+:let s:list=['abc', 'ab-c', 'def-ghi', 'adb']
+:let s:list2=['abc', 'def-b', 'geh']
+:let s:list3=['foo', 'bar', 'baz']
+:let s:dict={'abc': 1, 'adb': 1, 'aef': 1}
+#▶1 Built-in completion functions
+#▶2 path
+:call os.mkdir('FWCdirectory')
+:call os.chdir('FWCdirectory')
+:call os.mkdir('dir')
+:let abcdefghi=os.path.join('abc', 'def', 'ghi')
+:let dirdef   =os.path.join('dir', 'def')
+:let foodef   =os.path.join('foo', 'def')
+:let dirdefghi=os.path.join(dirdef, 'ghi')
+:call writefile([], 'foo', 'b')
+:call os.makedirs(abcdefghi)
+`path w
+  @+
+  abc\ dir\ foo
+
+  @f
+  foo
+
+  @i
+  dir\
+
+  @a\d
+  abc\def\
+
+  @a\d\
+  abc\def\ghi\
+
+  @T:\
+  T:\rtp\ T:\test\ T:\vimrc
+# vim: cms=#%s fmr=▶,▲ sw=2 ts=2 sts=2 et

test/gwine/fwccompletetests.dat

-!complete
-:let s:list=['abc', 'ab-c', 'def-ghi', 'adb']
-:let s:list2=['abc', 'def-b', 'geh']
-:let s:list3=['foo', 'bar', 'baz']
-:let s:dict={'abc': 1, 'adb': 1, 'aef': 1}
-#▶1 Built-in completion functions
-#▶2 in
-`in list
-  @+
-  =s:list
-
-  @b
-  abc ab-c adb
-
-  @j
-  =[]
-#▶2 key
-`key dict
-  @+
-  =sort(keys(s:dict))
-
-  @a
-  abc adb aef
-
-  @g
-  =[]
-#▶2 take
-`take dict exact
-  @+
-  =sort(keys(s:dict))
-
-  @a
-  abc adb aef
-
-  @g
-  =[]
-#▶2 either
-`either in list, key dict
-  @+
-  =s:list+sort(keys(s:dict))
-
-  @d
-  def-ghi
-#▶2 first
-`first in list, key dict
-  @+
-  =s:list
-
-  @d
-  def-ghi
-
-  @ae
-  aef
-#▶2 if
-`if match/^a/
-+   in dict
-+   in list3
-  @+
-  =s:list3
-
-  @a
-  =sort(keys(s:dict))
-#▶2 path
-:call os.mkdir('FWCdirectory')
-:call os.chdir('FWCdirectory')
-:call os.mkdir('dir')
-:let abcdefghi=os.path.join('abc', 'def', 'ghi')
-:let dirdef   =os.path.join('dir', 'def')
-:let foodef   =os.path.join('foo', 'def')
-:let dirdefghi=os.path.join(dirdef, 'ghi')
-:call writefile([], 'foo', 'b')
-:call os.makedirs(abcdefghi)
-`path w
-  @+
-  abc\ dir\ foo
-
-  @f
-  foo
-
-  @i
-  dir\
-
-  @a\d
-  abc\def\
-
-  @a\d\
-  abc\def\ghi\
-
-  @T:\
-  T:\rtp\ T:\test\ T:\vimrc
-#▶1 Different sections
-#▶2 {required}
-`in list
-  @+
-  =s:list
-
-  @b+
-  =[]
-`in list in list2
-  @+
-  =s:list
-
-  @b+
-  =s:list2
-#▶2 {actions}
-`<abc in list
-+ dbf in list2
-+ gh (in list2  key dict)>
-  @+
-  abc dbf gh
-
-  @b
-  abc dbf
-
-  @a+
-  =s:list
-
-  @d+
-  =s:list2
-
-  @g+
-  =s:list2
-
-  @g a+
-  =sort(keys(s:dict))
-
-`<abc in list
-+ dbf in list2
-+ gh (in list2  key dict)
-+ - (key dict  in list)>
-  @+
-  =["abc", "dbf", "gh"]+sort(keys(s:dict))
-
-  @a+
-  =s:list
-
-  @x+
-  =s:list
-# vim: cms=#%s fmr=▶,▲ sw=2 ts=2 sts=2 et

test/rtp/plugin/fwccomplete-os.vim

+execute frawor#Setup('0.0', {'@/fwc/compiler': '0.0',
+            \                '@/os':           '0.0'}, 1)
+let os=s:_r.os
+let i=1
+let j=1
+let sections=[]
+let prevsections=[]
+let toexecute=''
+let args=[]
+let FWC=''
+let FWCtype=''
+function ToList(line)
+    if a:line[0] is '='
+        return eval(a:line[1:])
+    else
+        if a:line[-1:] is '+'
+            return split(a:line[:-2])+['']
+        else
+            return split(a:line)
+        endif
+    endif
+endfunction
+for line in readfile('fwccompletetests-os.dat')
+    let line=substitute(line, '^\s*', '', '')
+    if empty(line)
+        continue
+    elseif line[0] is '#'
+        if char2nr(line[1:])==0x25b6
+            let level=+line[4:]
+            if level<=len(sections)
+                call remove(sections, level-1, -1)
+            endif
+            call add(sections, line[4+len(level)+1:])
+            let i=1
+        endif
+        continue
+    elseif line[0] is ':'
+        execute toexecute."\n".line[1:]
+        let toexecute=''
+        continue
+    elseif line[0] is '\'
+        let toexecute.="\n".line[1:]
+        continue
+    elseif line[0] is '@'
+        let args=[ToList(line[1:])]
+        continue
+    elseif line[0] is '`'
+        let FWC=line[1:]
+        continue
+    elseif line[0] is '+'
+        let FWC.=line[1:]
+        continue
+    elseif line[0] is '!'
+        let FWCtype=line[1:]
+        continue
+    elseif       (!empty($DEBUGTEST) && j!=$DEBUGTEST) ||
+                \(!empty($STARTFROM) && j<$STARTFROM)
+        let i+=1
+        let j+=1
+        continue
+    endif
+    if prevsections!=#sections
+        let prevsections=copy(sections)
+        echom '::: Section <'.join(sections, '/').'>'
+    endif
+    let compargs=[FWC, FWCtype]
+    let result=ToList(line)
+    if !empty($DEBUGTEST)
+        debug let ChFunc=call(s:_f.fwc_compile, compargs, {})
+        debug let realres=call(ChFunc, copy(args), {})
+    else
+        let ChFunc=call(s:_f.fwc_compile, compargs, {})
+        let realres=call(ChFunc, copy(args), {})
+    endif
+    if type(realres)!=type(result) || realres!=result
+        echom '[[[ Test #'.i.'('.j.') '.
+                    \'in section <'.join(sections, '/').'> failed:'
+        echom 'expected '.string(result).','
+        echom 'but got  '.string(realres)
+        echom 'Checked arguments: '.string(args)
+        echom 'FWC string: '.compargs[0]
+        echom 'Check type: '.compargs[1]
+        function g:.ChFunc
+        echom ']]]'
+        break
+    endif
+    let i+=1
+    let j+=1
+    unlet realres result
+endfor
+" vim: fmr=▶,▲