1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 23:10:04 +08:00
SpaceVim/bundle/deoplete.nvim/test/rplugin/python3/deoplete/test_matcher_fuzzy.py
2020-06-18 23:07:37 +08:00

69 lines
1.6 KiB
Python

from deoplete.filter.matcher_fuzzy import Filter
def _ctx(complete_str, ignorecase=True, camelcase=True):
_candidates = [
{ 'word': 'foobar' },
{ 'word': 'afoobar' },
{ 'word': 'fooBar' },
{ 'word': 'afooBar' },
{ 'word': 'Foobar' },
{ 'word': 'aFoobar' },
{ 'word': 'FooBar' },
{ 'word': 'aFooBar' },
]
return {
'complete_str' : complete_str,
'ignorecase' : ignorecase,
'camelcase' : camelcase,
'is_sorted' : False,
'candidates' : _candidates
}
def test_matcher_fuzzy():
f = Filter(None)
assert f.name == 'matcher_fuzzy'
assert f.description == 'fuzzy matcher'
ctx = _ctx('')
assert f.filter(ctx) == [
{ 'word': 'foobar' },
{ 'word': 'afoobar' },
{ 'word': 'fooBar' },
{ 'word': 'afooBar' },
{ 'word': 'Foobar' },
{ 'word': 'aFoobar' },
{ 'word': 'FooBar' },
{ 'word': 'aFooBar' },
]
ctx = _ctx('FOBR')
assert f.filter(ctx) == [
{ 'word': 'foobar' },
{ 'word': 'fooBar' },
{ 'word': 'Foobar' },
{ 'word': 'FooBar' },
]
ctx = _ctx('foBr', ignorecase=False)
assert f.filter(ctx) == [
{ 'word': 'fooBar' },
{ 'word': 'FooBar' },
]
ctx = _ctx('fobr', camelcase=False)
assert f.filter(ctx) == [
{ 'word': 'foobar' },
{ 'word': 'fooBar' },
{ 'word': 'Foobar' },
{ 'word': 'FooBar' },
]
ctx = _ctx('fobr', ignorecase=False, camelcase=False)
assert f.filter(ctx) == [
{ 'word': 'foobar' },
]