Commits

ZyX_I committed fa18f08

@/fwc: Improved fwccheck test, fixed some errors in `path' check

Comments (0)

Files changed (5)

plugin/frawor/fwc/compiler.vim

                 \.up().close()
                 \.nextthrow('!'.foundstr, 'nowrite', a:idx, '@#@', curargstr)
                 \.close()
+                \.up()
     return self
 endfunction
 "▶1 addtypecond    :: types, idx + self → self + self
                         let spec=spec[1:]
                     elseif spec[0] is 'p'
                         call self.addpathp(idx)
+                                    \.nextthrow('!@%@.os.path.isdir('.
+                                    \                             curargstr.')',
+                                    \           'isdir', idx, '@#@', curargstr)
+                                    \.close()
+                        let addedcond=0
                         let spec=spec[1:]
                     else
                         call self.nextthrow('!@%@.os.path.isdir('.curargstr.')',
                             let spec=spec[1:]
                         elseif spec[-1:] isnot 'x'
                             call self.nextthrow('@%@.os.path.isdir('.
-                                        \                         curargstr.')'.
+                                        \                         curargstr.')',
                                         \       'isfile', idx, '@#@', curargstr)
                         endif
                     endif
                     if spec[0] is 'w'
-                        call self.nextthrow('filewritable('.curargstr.')',
+                        call self.nextthrow('!filewritable('.curargstr.')',
                                     \       'nwrite', idx, '@#@', curargstr)
                         let spec=spec[1:]
                     elseif spec[0] is 'W'
-                        call self.nextthrow('filewritable('.curargstr.') &&'.
+                        call self.nextthrow('!filewritable('.curargstr.') &&'.
                                     \      '(@%@.os.path.exists('.curargstr.')'.
                                     \       '|| filewritable('.
                                     \               '@%@.os.path.dirname('.
                                     \      'nowrite', idx, '@#@', curargstr)
                         let spec=spec[1:]
                     elseif spec[0] is 'p'
-                        call self.addpathp(idx)
+                        call self.addpathp(idx).close()
+                        let addedcond=0
                         let spec=spec[1:]
                     endif
                     if spec is 'x'
                                     \       'nexecable', idx, '@#@', curargstr)
                     endif
                 endif
-                call self.up()
             "▶3 `type'
             elseif desc[0] is 'type'
                 let addedcond=1

plugin/frawor/fwc/parser.vim

 " Gets path specification:
 " Input: [( "d" | "f" )] [ "r" ] [( "w" | "W" | "p" )] [ "x" ]
 "        & ! ( "d" | ^ ) "r"
-"        & ! ( "d" ) [( "w" | "W" | "p" )] "x"
+"        & ! ( "d" ) ( "w" | "W" | "p" )? "x"
 " 1. "d" for directory and "f" for regular file, otherwise both may be accepted
 " 2. "r" for readable file (not directory)
 " 3. "w" for writeable file or directory (unless "f" is specified),
 plugin/frawor/fwc/compiler:ninlist
 plugin/frawor/fwc/compiler:ninlist
 ::: Section <Checks/Built-in checks/path>
+plugin/frawor/fwc/compiler:nwrite
+plugin/frawor/fwc/compiler:nowrite
+plugin/frawor/fwc/compiler:nowrite
+plugin/frawor/fwc/compiler:nowrite
+plugin/frawor/fwc/compiler:isfile
+plugin/frawor/fwc/compiler:isdir
+plugin/frawor/fwc/compiler:nread
 ::: Section <Checks/Built-in checks/either>
 plugin/frawor/fwc/compiler:nbool
 plugin/frawor/fwc/compiler:typefail

test/fwctests.dat

 ['_',               'check'], [[[[]]]],             1
 ['any',             'check'], [[[[]]]],             1
 #▶3 path
+:call os.mkdir('FWCdirectory')
+:call os.chdir('FWCdirectory')
+:call os.mkdir('dir')
+:let curdir=os.path.realpath('.')
+: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')
+['path w',          'check'], ['foo'],              1
+['path w',          'check'], ['bar'],              0
+['path W',          'check'], ['foo'],              1
+['path W',          'check'], ['bar'],              1
+['path W',          'check'], [dirdefghi],          0
+['path W',          'check'], [dirdef],             1
+['path dW',         'check'], ['foo'],              0
+['path dW',         'check'], ['bar'],              1
+['path dW',         'check'], [dirdef],             1
 ['path p',          'check'], ['abc'],              1
+['path p',          'check'], [abcdefghi],          1
+['path p',          'check'], [dirdefghi],          1
+['path p',          'check'], ['.'],                1
+['path p',          'check'], ['foo'],              1
+['path p',          'check'], [foodef],             0
+['path fp',         'check'], ['foo'],              1
+['path fp',         'check'], ['dir'],              0
+['path dp',         'check'], ['foo'],              0
+['path dp',         'check'], ['dir'],              1
+['path dp',         'check'], [dirdefghi],          1
+['path fr',         'check'], ['.'],                0
+['path fr',         'check'], ['foo'],              1
 #▶3 either
 ['either bool, isreg',      'check'], ['abc'],         1
 ['either bool, isreg',      'check'], [2],             0

test/rtp/plugin/fwccheck.vim

-execute frawor#Setup('0.0', {'@/fwc/compiler': '0.0'}, 1)
+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=[]