Commits

ZyX_I committed f98913f

@/fwc: Added `is' check

  • Participants
  • Parent commits 03271c3

Comments (0)

Files changed (5)

File plugin/frawor/autocommands.vim

 "▶2 augroup.add  :: {f}, agid, [event] → + :autocmd, s:augroups
 function s:F.augroup.add(plugdict, fdict, agid, events)
     "▶3 Check arguments
-    if type(a:agid)!=type("")
+    if type(a:agid)!=type('')
         call s:_f.throw('agidnstr', a:plugdict.id)
     elseif a:agid!~#'^\w\+$'
         call s:_f.throw('invagid', a:plugdict.id, a:agid)

File plugin/frawor/fwc/compiler.vim

             \ 'keynmatch': 'key `%s'' does not match any specification',
             \    'nmatch': 'no matches found for %s',
             \   'notfail': '`not'' check failed',
+            \     'isnot': 'expected %s, but got %s',
         \}, '"Error while processing check %s for %s: ".v:val'))
 let s:_messages._types=['number', 'string', 'function reference', 'list',
             \           'dictionary']
                 let addedcond=1
                 call self.nextthrow('index([0, 1], '.curargstr.')==-1',
                             \       'nbool', idx,'@#@', 'string('.curargstr.')')
+            "▶3 `is'
+            elseif desc[0] is 'is'
+                let addedcond=1
+                let var=self.getvar(desc[1])
+                call self.nextthrow(curargstr.' isnot '.var,
+                            \       'isnot', idx, '@#@', var,
+                            \                'string('.curargstr.')')
             "▶3 `_', `any'
             elseif desc[0] is '_' || desc[0] is 'any'
                 " Just do nothing here

File plugin/frawor/fwc/parser.vim

 "▶3 check.bool
 " Checks whether {argument} is either 0 or 1
 let s:args.check.bool=[]
+"▶3 check.is
+" Checks whether {argument} is {var}
+let s:args.check.is=['var']
 "▶3 check._, check.any
 " Unconditionally accepts {argument}
 let s:args.check._=[]

File test/fwccheck.ok

 plugin/frawor/fwc/compiler:nindict
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:notfail
+plugin/frawor/fwc/compiler:isnot
 ::: Section <Checks/Built-in checks/in>
 plugin/frawor/fwc/compiler:ninlist
 plugin/frawor/fwc/compiler:ninlist

File test/fwctests.dat

 ['key={"abc": 1}',  'check'], [0],                  0
 ['not bool',        'check'], [0],                  0
 ['not bool',        'check'], [2],                  1
+['is =2',           'check'], [2],                  1
+['is =2',           'check'], [[]],                 0
 ['_',               'check'], [[[[]]]],             1
 ['any',             'check'], [[[[]]]],             1
 #▶3 in