frawor / test / fwctests.dat

#▶1 Invalid length
#▶2 Required
['_',                    'check'], range(0), 0
['_',                    'check'], range(2), 0
['_ _',                  'check'], range(3), 0
['()',                   'check'], range(1), 0
#▶2 Optinal
['[_]',                  'check'], range(2), 0
['[_][_ _]',             'check'], range(3), 0
['[_][_[_]]',            'check'], range(4), 0
['[_ [_ _]]',            'check'], range(4), 0
#['[_][_ _ _]',           'check'], range(2), 0
['[]',                   'check'], range(1), 0
#▶2 Required+optional
['_[_]',                 'check'], range(0), 0
['_[_[_]]',              'check'], range(4), 0
['_[_[_][_ _]]',         'check'], range(5), 0
['()[]',                 'check'], range(1), 0
#▶2 Required+next
['_+_',                  'check'], range(0), 0
['_ _ _ +_',             'check'], range(2), 0
#▶2 Required+optional+next
['_[_]+_',               'check'], range(0), 0
['_[_+_]',               'check'], range(0), 0
['_[[_]+_]',             'check'], range(0), 0
#▶2 Prefixes
['{p1 _}',               'check'], range(0), 0
['{p1 _}',               'check'], range(1), 0
['{+2 p1 _ _}',          'check'], range(2), 0
['{*p1 _}',              'check'], range(0), 0
['{p2 _ *p1 _}',         'check'], range(3), 0
['{?p1 _ !p2 -}',        'check'], range(0), 0
['{}',                   'check'], range(1), 0
#▶2 Actions+required
['<a1 ->',               'check'], range(0), 0
['<a1 ->',               'check'], range(2), 0
['<- _>',                'check'], range(0), 0
['<- _>',                'check'], range(2), 0
['<a1 - a2 _ a3 (_ _)>', 'check'], range(0), 0
['<a1 - a2 _ a3 (_ _)>', 'check'], range(4), 0
['<- ->',                'check'], range(1), 0
['<>',                   'check'], range(1), 0
#▶2 Actions+optional
['<a1 [_]>',             'check'], range(0), 0
['<a1 [_]>',             'check'], range(3), 0
['<- []>',               'check'], range(1), 0
#▶2 Actions+actions+required
['<a1 <a2 _>>',          'check'], range(2), 0
['<a1 <a2 _>>',          'check'], range(4), 0
['<- <- ->>',            'check'], range(1), 0
#▶1 Pipes
\function s:.revstring(str)
\    return join(reverse(split(a:str, '\v.@=')), '')
:endfunction
#▶2 Function pipes
['|*$"string"',                'filter'], ['abc'], ["'abc'"]
["|*$'string'",                'filter'], ['abc'], ["'abc'"]
['|*=function("string")',      'filter'], ['abc'], ["'abc'"]
['|*revstring',                'filter'], ['abc'], ['cba']
['|*$"string"(.)',             'filter'], ['abc'], ["'abc'"]
['|*=function("string")(.)',   'filter'], ['abc'], ["'abc'"]
['|*revstring(.)',             'filter'], ['abc'], ['cba']
['|*$"split"(. ''\v.@='')',    'filter'], ['abc'], [['a', 'b', 'c']]
['|*$"index"([abc def ghi])',  'filter'], ['abc'], [0]
['|*@',                        'filter'], [function('string')], ['function(''string'')']
['(|*@>) _',                   'filter'], ['abc', function('string')], ["'abc'", function('string')]
['_ |*@<',                     'filter'], [function('string'), 'abc'], [function('string'), "'abc'"]
['|*=((@.@[0] is "a")?(function("string")):(function("eval")))(.)', 'filter'], ['a0'], ["'a0'"]
['|*=((@.@[0] is "a")?(function("string")):(function("eval")))(.)', 'filter'], ['0'],  [0]
#▶2 Expression pipes
['|=string(@.@)',              'filter'], ['abc'], ["'abc'"]
#▶2 Built-in pipes
['func$"string"',          'filter'], ['abc'],              ["'abc'"]
['func revstring',         'filter'], ['abc'],              ['cba']
['eval string(@.@)',       'filter'], ['abc'],              ["'abc'"]
['run [abc]',              'filter'], ['string'],           ["'abc'"]
['run [abc]',              'filter'], [function('string')], ["'abc'"]
['run []',                 'filter'], ['()'],               0
['run [$[abc def]]',       'filter'], [s:.revstring],       0
['earg',                   'filter'], ['string("abc")'],    ["'abc'"]
['earg',                   'filter'], ['('],                0
['isfunc',                 'filter'], [0],                  0
['isfunc',                 'filter'], [function('tr')],     [function("tr")]
['take ={"abc": 1} start', 'filter'], ['a'],                [1]
['take ={"abc": 1} start', 'filter'], ['b'],                0
['take ={"abc": 1} start', 'filter'], [0],                  0
#▶3 dict
['dict {abc bool}',        'filter'], [{'abc': {}}],        [{'abc': 0}]
['dict {abc bool}',        'filter'], [{'ab': {}}],         0
['dict {/^a/ bool}',       'filter'], [{'a': 2, 'ab': {}}], [{'a': 1, 'ab': 0}]
['dict {/^a/ bool}',       'filter'], [{'a': 2, 'Ab': {}}], 0
['dict {a isreg}',         'filter'], [{'a': '\v('}],       0
['dict {?isreg bool}',     'filter'], [{'abc': {}}],        [{'abc': 0}]
['dict {?isreg bool}',     'filter'], [{'\v(': {}}],        0
['dict {?isreg bool ?_ _}','filter'], [{'a': 4, '\v(': 2}], [{'a': 1, '\v(': 2}]
['dict {a _ ?isreg bool}', 'filter'], [{'a': 4, 'ab':  2}], [{'a': 4, 'ab':  1}]
['dict {*$"exists" bool}', 'filter'], [{'g:': []}],         [{'g:': 0}]
['dict {*$"exists" bool}', 'filter'], [{'g:+': []}],        0
['dict {=exists(@.@)bool}','filter'], [{'g:': []}],         [{'g:': 0}]
['dict {=exists(@.@)bool}','filter'], [{'g:+': []}],        0
['dict {- bool}',          'filter'], [{'abc': []}],        [{'abc': 0}]
['dict {abc bool - _}',    'filter'], [{'abc':[], 'ab':2}], [{'abc':0, 'ab':2}]
['dict {?isreg bool - _}', 'filter'], [{'a': [], '\v(': 2}],[{'a': 0, '\v(': 2}]
#▶3 tuple
['tuple bool, bool',       'filter'], [['', 'cba']],        [[0, 1]]
['tuple bool, bool',       'filter'], [['abc']],            0
['tuple bool, bool',       'filter'], ['abc'],              0
['tuple (?bool |=(!@.@))', 'filter'], [[1]],                [[0]]
['tuple (tuple bool tuple bool, bool)', 'filter'], [[[''],[4,0]]], [[[0],[1,0]]]
#▶3 list
['list bool',              'filter'], ["['abc', 'def']"],   0
['list bool',              'filter'], [['abc', 'def']],     [[1, 1]]
['list tuple bool, bool',  'filter'], [['ab', 'de']],       0
['list tuple bool, bool',  'filter'], [[[1, 2], [0, 3]]],   [[[1, 1], [0, 1]]]
['list list list ?bool',   'filter'], [1],                  0
['list list list ?bool',   'filter'], [[1]],                0
['list list list ?bool',   'filter'], [[[1]]],              0
['list list list ?bool',   'filter'], [[[[1]]]],            [[[[1]]]]
['list list list ?bool',   'filter'], [[[[[]]]]],           0
['list list list ?bool',   'filter'], [[[[1], [0, 1]]]],    [[[[1], [0, 1]]]]
['list (?bool |=(!@.@))',  'filter'], [[1, 0, 1]],          [[0, 1, 0]]
#▶3 key
['key={"abc": 1}~exact',   'filter'], ['abc'],              ['abc']
['key={"abc": 1}',         'filter'], ['abc'],              ['abc']
['key={"abc": 1}',         'filter'], ['ab'],               0
['key={"abc": 1}',         'filter'], [0],                  0
['key={"abc": 1}~start',   'filter'], ['a'],                ['abc']
#▶3 in
['in [abc def]',           'filter'], ['abc'],              ['abc']
['in =["a","b"]',          'filter'], ['abc'],              0
['in =["a",0]',            'filter'], ['a'],                ['a']
['in =["a",0]',            'filter'], ['0'],                0
['in =["a",0]',            'filter'], [0],                  [0]
['in =["a",0]~exact 0',    'filter'], [0],                  [0]
:let s:list=['abc', 'def', 'abc-def', 'Abc', 'dEf', 'aBc-deF', 'Ghi']
['in list ~exact',         'filter'], ['abc'],              ['abc']
['in list ~exact 1',       'filter'], ['ghi'],              ['Ghi']
['in list ~exact 1',       'filter'], ['gh'],               0
['in list ~start',         'filter'], ['gh'],               0
['in list ~start',         'filter'], ['ab'],               0
['in list ~start 0 1',     'filter'], ['ab'],               ['abc']
['in list ~start 1',       'filter'], ['gh'],               ['Ghi']
['in list ~smart',         'filter'], ['a-d'],              0
['in list ~smart',         'filter'], ['b-d'],              ['abc-def']
['in list ~smart 1',       'filter'], ['a-d'],              ['abc-def']
#▶3 substitute
:let s:regex='\v.'
:let s:replacement='def'
:let s:flags='g'
['substitute/abc/"def"""', 'filter'], ['abc'],              ['def']
['substitute/abc/"def"""', 'filter'], [0],                  0
['substitute/abc/"def"g',  'filter'], ['abcabc'],           ['defdef']
['substitute/abc/"def"""', 'filter'], ['abcabc'],           ['defabc']
['substitute$regex$replacement$flags', 'filter'], ['abc'],  ['defdefdef']
#▶3 bool
['bool',                   'filter'], [[]],                 [0]
['bool',                   'filter'], [{}],                 [0]
['bool',                   'filter'], [""],                 [0]
['bool',                   'filter'], [0],                  [0]
['bool',                   'filter'], [1],                  [1]
['bool',                   'filter'], ["abc"],              [1]
['bool',                   'filter'], [[0]],                [1]
['bool',                   'filter'], [{1:2}],              [1]
#▶2 Pipes composition
['|*$"string"|*$"string"',     'filter'], ['abc'], ["'''abc'''"]
['|=string(@.@)|=string(@.@)', 'filter'], ['abc'], ["'''abc'''"]
#▶1 Checks
\function s:.ordered(str)
\    return join(sort(split(a:str, '\v.@=')), '') is a:str
:endfunction
:let s:d={}
:let s:d.list=range(4)
:let s:listname='list'
:let s:ss=1
:let s:es=2
#▶2 Function checks
['?*$"empty"', 'check'], ['abc'], 0
['?*$"empty"', 'check'], [''],    1
['?*ordered',  'check'], ['abc'], 1
['?*ordered',  'check'], ['acb'], 0
#▶2 Expression checks
['?=empty(@.@)', 'check'], ['abc'], 0
['?=empty(@.@)', 'check'], [''],    1
#▶2 Built-in checks
['func ordered',    'check'], ['abc'],              1
['func ordered',    'check'], ['acb'],              0
['eval empty(@.@)', 'check'], ['abc'],              0
['eval empty(@.@)', 'check'], [''],                 1
['bool',            'check'], [''],                 0
['bool',            'check'], [0],                  1
['bool',            'check'], [1],                  1
['bool',            'check'], [2],                  0
['isreg',           'check'], [0],                  0
['isreg',           'check'], ['\v(abc)'],          1
['isreg',           'check'], ['\v(abc'],           0
['key={"abc": 1}',  'check'], ['abc'],              1
['key={"abc": 1}',  'check'], ['ab'],               0
['key={"abc": 1}',  'check'], [0],                  0
['not bool',        'check'], [0],                  0
['not bool',        'check'], [2],                  1
['_',               'check'], [[[[]]]],             1
['any',             'check'], [[[[]]]],             1
#▶3 in
['in [abc def]',    'check'], ['abc'],              1
['in =["a","b"]',   'check'], ['abc'],              0
['in =["a",0]',     'check'], ['a'],                1
['in =["a",0]',     'check'], ['0'],                0
['in =["a",0]',     'check'], [0],                  1
#▶4 Subscripts checks
['in d.list',         'check'], [0],                1
['in d.list',         'check'], [5],                0
['in d."list"',       'check'], [0],                1
['in d."list"',       'check'], [5],                0
['in d.''list''',     'check'], [0],                1
['in d.''list''',     'check'], [5],                0
['in d.$listname',    'check'], [0],                1
['in d.$listname',    'check'], [5],                0
['in d.list.:$ss$es', 'check'], [2],                1
['in d.list.:$ss$es', 'check'], [0],                0
['in d.list.:1 2',    'check'], [2],                1
['in d.list.:1 2',    'check'], [0],                0
#▶3 dict
['dict {}',                   'check'], [{}],              1
['dict {}',                   'check'], [{'a': 1}],        0
['dict {}',                   'check'], [[]],              0
['dict {abc bool}',           'check'], [{'abc': 1}],      1
['dict {abc bool}',           'check'], [{'abc': 2}],      0
['dict {/^a/ bool}',          'check'], [{'a':1, 'ab':0}], 1
['dict {/^a/ bool}',          'check'], [{'a':1, 'ab':2}], 0
['dict {/^a/ bool}',          'check'], [{'a':1, 'Ab':2}], 0
['dict {*ordered bool}',      'check'], [{'abc': 1}],      1
['dict {*ordered(.) bool}',   'check'], [{'abc': 1}],      1
['dict {*ordered bool}',      'check'], [{'bac': 1}],      0
['dict {=exists(@.@) bool}',  'check'], [{'g:': 0}],       1
['dict {=exists(@.@) bool}',  'check'], [{'g:': 2}],       0
['dict {=exists(@.@) bool}',  'check'], [{'g:+': 1}],      0
['dict {?|earg bool bool}',   'check'], [{'0': 1}],        1
['dict {?|earg bool bool}',   'check'], [{'0': 2}],        0
['dict {?|earg bool bool}',   'check'], [{'2': 1}],        0
['dict {- isreg}',            'check'], [{'a': 'abc'}],    1
['dict {- isreg}',            'check'], [{'a': '\v('}],    0
#▶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
['either bool, isreg',      'check'], [0],             1
['either bool, isreg bool', 'check'], [0, 2],          0
#▶3 list
['list isreg',              'check'], ["['abc']"],     0
['list isreg',              'check'], [['abc']],       1
['list isreg',              'check'], [['abc', '\(']], 0
['list (isreg match /^a/)', 'check'], [['abc']],       1
['list (isreg match /^a/)', 'check'], [['a','b']],     0
#▶3 tuple
['tuple (?isreg match /^a/)', 'check'], [['a', 'b']],      0
['tuple (?isreg match /^a/)', 'check'], [['a']],           1
['tuple (?isreg match /^a/)', 'check'], [['.']],           0
['tuple (?isreg match /^a/)', 'check'], [['a\(']],         0
['tuple isreg, isreg',        'check'], [['abc', 'cba']],  1
['tuple isreg, isreg',        'check'], [['abc', '\(']],   0
['tuple isreg, isreg',        'check'], [['abc']],         0
['tuple isreg, isreg',        'check'], ['abc'],           0
['tuple bool, bool, bool',    'check'], [[0, 1, 0]],       1
['?tuple bool, bool, bool',  'filter'], [[0, 1, ""]],      0
#▶3 range
:let s:n1=-1
:let s:n2=1
['range  0   2',    'check'], ['1'],                0
['range  0   2',    'check'], [-1],                 0
['range  0   2',    'check'], [0],                  1
['range  0   2',    'check'], [1],                  1
['range  0   2',    'check'], [2],                  1
['range  0   2',    'check'], [3],                  0
['range  0  inf',   'check'], [3],                  1
['range inf inf',   'check'], [3],                  1
['range inf  2',    'check'], [-1],                 1
['range $n1 $n2',   'check'], [0],                  1
['range $n1 $n2',   'check'], [3],                  0
#▶3 haskey
:let s:k1='def'
['haskey abc',      'check'], [""],                 0
['haskey abc',      'check'], [{}],                 0
['haskey abc, def', 'check'], [{}],                 0
['haskey abc, def', 'check'], [{'abc': 1}],         0
['haskey abc, def', 'check'], [{'abc':1, 'def':1}], 1
['haskey abc',      'check'], [{'abc': 1}],         1
['haskey $k1, abc', 'check'], [{'abc': 1}],         0
['haskey $k1, abc', 'check'], [{'abc':1, 'def':1}], 1
['haskey $k1',      'check'], [{'abc': 1}],         0
['haskey $k1',      'check'], [{'def': 1}],         1
#▶3 isfunc
['isfunc',          'check'], [function('tr')],     1
['isfunc',          'check'], [function('s:Eval')], 0
['isfunc',          'check'], ['tr'],               1
['isfunc',          'check'], ['s:Eval'],           0
['isfunc 1',        'check'], [function('tr')],     1
['isfunc 1',        'check'], ['tr'],               0
['isfunc 1',        'check'], [function('s:Eval')], 0
# The following may throw an exception
['isfunc',          'check'], ['()'],               0
['isfunc',          'check'], ['g:[xx]'],           0
#▶3 match
['match/\vb@<!a/',  'check'], ['abc'],              1
['match/\vb@<!a/',  'check'], ['bac'],              0
['match/\vb@<!a/',  'check'], [0],                  0
['match$regex',     'check'], [''],                 0
['match$regex',     'check'], ['abc'],              1
#▶3 type
['type string',     'check'], [''],                 1
['type string',     'check'], [0],                  0
['type ""',         'check'], [''],                 1
['type ""',         'check'], [0],                  0
["type ''",         'check'], [''],                 1
["type ''",         'check'], [0],                  0
['type number',     'check'], [0],                  1
['type number',     'check'], [[]],                 0
['type -0',         'check'], [0],                  1
['type -0',         'check'], [[]],                 0
['type -',          'check'], [0],                  1
['type -',          'check'], [[]],                 0
['type dictionary', 'check'], [{}],                 1
['type dictionary', 'check'], [[]],                 0
['type {}',         'check'], [{}],                 1
['type {}',         'check'], [[]],                 0
['type list',       'check'], [[]],                 1
['type list',       'check'], [""],                 0
['type []',         'check'], [[]],                 1
['type []',         'check'], [""],                 0
['type function',   'check'], [function("tr")],     1
['type function',   'check'], [function("s:Eval")], 1
['type function',   'check'], ["tr"],               0
# Not checking float here: it may be absent on some setups
['type {}, []',     'check'], [{}],                 1
['type {}, []',     'check'], [[]],                 1
['type {}, []',     'check'], [""],                 0
#▶2 Check composition
['?=!empty(@.@)?=(type(@.@)==type(""))?=(@.@[0]=="a")', 'check'], ['abc'], 1
['?=!empty(@.@)?=(type(@.@)==type(""))?=(@.@[0]=="a")', 'check'], [''],    0
['?=!empty(@.@)?=(type(@.@)==type(""))?=(@.@[0]=="a")', 'check'], [[1]],   0
['?=!empty(@.@)?=(type(@.@)==type(""))?=(@.@[0]=="a")', 'check'], ['bac'], 0
#▶2 Checks and pipes composition
#▶1 Messages
:let s:_messages={}
:let s:_messages.str='%s<'
['#str(%) bool',                         'check'], [2],        0
['#str(%) bool (type "" #str(.) isreg)', 'check'], [1, '\v('], 0
['#str(*$"type"(@)) bool',               'check'], [2],        0
['#str(*$"type"(@)) bool',               'check'], [""],       0
# vim: cms=#%s fmr=▶,▲
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.