Fixed vim and zsh

This commit is contained in:
2018-04-05 13:06:54 +02:00
parent f9db886bd3
commit 0331f6518a
2009 changed files with 256303 additions and 0 deletions

View File

@ -0,0 +1,24 @@
let s:suite = themis#suite('custom')
let s:assert = themis#helper('assert')
function! s:suite.custom() abort
call deoplete#custom#init()
call deoplete#custom#source('_',
\ 'matchers', ['matcher_head'])
call deoplete#custom#source('_', 'converters',
\ ['converter_auto_delimiter', 'remove_overlap'])
call s:assert.equals(
\ deoplete#custom#get().source,
\ {'_' : {
\ 'matchers': ['matcher_head'],
\ 'converters': ['converter_auto_delimiter', 'remove_overlap']}})
call deoplete#custom#init()
call deoplete#custom#source('buffer',
\ 'min_pattern_length', 9999)
call deoplete#custom#source('buffer', 'rank', 9999)
endfunction

View File

@ -0,0 +1,27 @@
let s:suite = themis#suite('parser')
let s:assert = themis#helper('assert')
function! s:suite.vimoption2python() abort
call s:assert.equals(
\ deoplete#util#vimoption2python('@,48-57,_,\'), '[a-zA-Z@0-9_\\]')
call s:assert.equals(
\ deoplete#util#vimoption2python('@,-,48-57,_'), '[a-zA-Z@0-9_-]')
call s:assert.equals(
\ deoplete#util#vimoption2python('@,,,48-57,_'), '[a-zA-Z@,0-9_]')
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.10', '0.1.8'), 2)
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.10', '0.1.10'), 0)
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.10', '0.1.0010'), 0)
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.1', '0.1.8'), -7)
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.1000', '0.1.10'), 990)
call s:assert.equals(
\ deoplete#util#versioncmp('0.1.0001', '0.1.10'), -9)
call s:assert.equals(
\ deoplete#util#versioncmp('2.0.1', '1.3.5'), 9696)
call s:assert.equals(
\ deoplete#util#versioncmp('3.2.1', '0.0.0'), 30201)
endfunction

View File

@ -0,0 +1,5 @@
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(BASE_DIR, 'rplugin/python3'))

View File

@ -0,0 +1,35 @@
import deoplete.util as util
from deoplete.filter.converter_remove_overlap import overlap_length
def test_fuzzy_escapse():
assert util.fuzzy_escape('foo', 0) == 'f[^f]*o[^o]*o[^o]*'
assert util.fuzzy_escape('foo', 1) == 'f[^f]*o[^o]*o[^o]*'
assert util.fuzzy_escape('Foo', 1) == 'F[^F]*[oO].*[oO].*'
def test_overlap_length():
assert overlap_length('foo bar', 'bar baz') == 3
assert overlap_length('foobar', 'barbaz') == 3
assert overlap_length('foob', 'baz') == 1
assert overlap_length('foobar', 'foobar') == 6
assert overlap_length('тест', 'ст') == len('ст')
def test_charwidth():
assert util.charwidth('f') == 1
assert util.charwidth('') == 2
def test_strwidth():
assert util.strwidth('foo bar') == 7
assert util.strwidth('あいうえ') == 8
assert util.strwidth('fooあい') == 7
def test_truncate():
assert util.truncate('foo bar', 3) == 'foo'
assert util.truncate('fooあい', 5) == 'fooあ'
assert util.truncate('あいうえ', 4) == 'あい'
assert util.truncate('fooあい', 4) == 'foo'
def test_skipping():
assert util.truncate_skipping('foo bar', 3, '..', 3) == '..bar'
assert util.truncate_skipping('foo bar', 6, '..', 3) == 'f..bar'
assert util.truncate_skipping('fooあい', 5, '..', 3) == 'f..い'
assert util.truncate_skipping('あいうえ', 6, '..', 2) == 'あ..え'

View File

@ -0,0 +1,59 @@
from deoplete.filter.matcher_full_fuzzy import Filter
from test_matcher_fuzzy import _ctx
def test_matcher_full_fuzzy():
f = Filter(None)
assert f.name == 'matcher_full_fuzzy'
assert f.description == 'full 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': 'afoobar' },
{ 'word': 'fooBar' },
{ 'word': 'afooBar' },
{ 'word': 'Foobar' },
{ 'word': 'aFoobar' },
{ 'word': 'FooBar' },
{ 'word': 'aFooBar' },
]
ctx = _ctx('foBr', ignorecase=False)
assert f.filter(ctx) == [
{ 'word': 'fooBar' },
{ 'word': 'afooBar' },
{ 'word': 'FooBar' },
{ 'word': 'aFooBar' },
]
ctx = _ctx('fobr', camelcase=False)
assert f.filter(ctx) == [
{ 'word': 'foobar' },
{ 'word': 'afoobar' },
{ 'word': 'fooBar' },
{ 'word': 'afooBar' },
{ 'word': 'Foobar' },
{ 'word': 'aFoobar' },
{ 'word': 'FooBar' },
{ 'word': 'aFooBar' },
]
ctx = _ctx('fobr', ignorecase=False, camelcase=False)
assert f.filter(ctx) == [
{ 'word': 'foobar' },
{ 'word': 'afoobar' },
]

View File

@ -0,0 +1,67 @@
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' },
]

View File

@ -0,0 +1,69 @@
import deoplete.util as util
def test_pos():
assert util.bytepos2charpos('utf-8', 'foo bar', 3) == 3
assert util.bytepos2charpos('utf-8', 'あああ', 3) == 1
assert util.charpos2bytepos('utf-8', 'foo bar', 3) == 3
assert util.charpos2bytepos('utf-8', 'あああ', 3) == 9
def test_custom():
custom = {'source':{}}
custom['source'] = {'_': {'mark': ''}, 'java': {'converters': []}}
assert util.get_custom(custom, 'java', 'mark', 'foobar') == ''
assert util.get_custom(custom, 'java', 'converters', 'foobar') == []
assert util.get_custom(custom, 'foo', 'mark', 'foobar') == ''
assert util.get_custom(custom, 'foo', 'converters', 'foobar') == 'foobar'
def test_globruntime():
assert util.globruntime('/usr', 'bin') == ['/usr/bin']
def test_binary_search():
assert util.binary_search_begin([], '') == -1
assert util.binary_search_begin([{'word': 'abc'}], 'abc') == 0
assert util.binary_search_begin([
{'word': 'aaa'}, {'word': 'abc'},
], 'abc') == 1
assert util.binary_search_begin([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'abc'},
], 'abc') == 2
assert util.binary_search_begin([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'AbC'},
], 'abc') == 2
assert util.binary_search_begin([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'abc'},
], 'b') == -1
assert util.binary_search_begin([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'aac'}, {'word': 'abc'},
], 'aa') == 1
assert util.binary_search_end([], '') == -1
assert util.binary_search_end([{'word': 'abc'}], 'abc') == 0
assert util.binary_search_end([
{'word': 'aaa'}, {'word': 'abc'},
], 'abc') == 1
assert util.binary_search_end([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'abc'},
], 'abc') == 2
assert util.binary_search_end([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'abc'},
], 'b') == -1
assert util.binary_search_end([
{'word': 'a'}, {'word': 'aaa'}, {'word': 'aac'}, {'word': 'abc'},
], 'aa') == 2
def test_uniq_list_dict():
assert util.uniq_list_dict([
{'abbr': 'word', 'word': 'foobar'},
{'word': 'bar'},
{'word': 'foobar', 'abbr': 'word'},
{'word': 'baz'},
]) == [
{'word': 'foobar', 'abbr': 'word'},
{'word': 'bar'},
{'word': 'baz'}
]