2014-10-22 15:50:54 -07:00
|
|
|
-- Tests for Unicode manipulations
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2014-10-22 15:50:54 -07:00
|
|
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
local command, expect = helpers.command, helpers.expect
|
2016-01-30 09:42:22 -07:00
|
|
|
local eq, eval = helpers.eq, helpers.eval
|
2016-02-15 07:43:27 -07:00
|
|
|
local source = helpers.source
|
2017-04-08 14:12:26 -07:00
|
|
|
local wait = helpers.wait
|
2014-10-22 15:50:54 -07:00
|
|
|
|
|
|
|
describe('utf8', function()
|
2016-02-15 07:43:27 -07:00
|
|
|
before_each(clear)
|
2014-10-22 15:50:54 -07:00
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
insert('start:')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('new')
|
|
|
|
command('call setline(1, ["aaa", "あああ", "bbb"])')
|
2014-10-22 15:50:54 -07:00
|
|
|
|
|
|
|
-- Visual block Insert adjusts for multi-byte char
|
|
|
|
feed('gg0l<C-V>jjIx<Esc>')
|
2017-04-08 14:12:26 -07:00
|
|
|
wait()
|
2014-10-22 15:50:54 -07:00
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('let r = getline(1, "$")')
|
|
|
|
command('bwipeout!')
|
|
|
|
command('$put=r')
|
|
|
|
command('call garbagecollect(1)')
|
2014-10-22 15:50:54 -07:00
|
|
|
|
|
|
|
expect([[
|
|
|
|
start:
|
|
|
|
axaa
|
|
|
|
xあああ
|
|
|
|
bxbb]])
|
|
|
|
end)
|
2016-01-30 09:42:22 -07:00
|
|
|
|
|
|
|
it('strchars()', function()
|
|
|
|
eq(1, eval('strchars("a")'))
|
|
|
|
eq(1, eval('strchars("a", 0)'))
|
|
|
|
eq(1, eval('strchars("a", 1)'))
|
|
|
|
|
|
|
|
eq(3, eval('strchars("あいa")'))
|
|
|
|
eq(3, eval('strchars("あいa", 0)'))
|
|
|
|
eq(3, eval('strchars("あいa", 1)'))
|
|
|
|
|
|
|
|
eq(2, eval('strchars("A\\u20dd")'))
|
|
|
|
eq(2, eval('strchars("A\\u20dd", 0)'))
|
|
|
|
eq(1, eval('strchars("A\\u20dd", 1)'))
|
|
|
|
|
|
|
|
eq(3, eval('strchars("A\\u20dd\\u20dd")'))
|
|
|
|
eq(3, eval('strchars("A\\u20dd\\u20dd", 0)'))
|
|
|
|
eq(1, eval('strchars("A\\u20dd\\u20dd", 1)'))
|
|
|
|
|
|
|
|
eq(1, eval('strchars("\\u20dd")'))
|
|
|
|
eq(1, eval('strchars("\\u20dd", 0)'))
|
|
|
|
eq(1, eval('strchars("\\u20dd", 1)'))
|
|
|
|
end)
|
2016-02-15 07:43:27 -07:00
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 613 (Trailing whitespace in a string)
|
2016-02-15 07:43:27 -07:00
|
|
|
it('customlist completion', function()
|
|
|
|
source([[
|
|
|
|
function! CustomComplete1(lead, line, pos)
|
|
|
|
return ['あ', 'い']
|
|
|
|
endfunction
|
2016-02-15 08:17:07 -07:00
|
|
|
command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo]])
|
2016-02-15 07:43:27 -07:00
|
|
|
feed(":Test1 <C-L>'<C-B>$put='<CR>")
|
|
|
|
|
|
|
|
source([[
|
|
|
|
function! CustomComplete2(lead, line, pos)
|
|
|
|
return ['あたし', 'あたま', 'あたりめ']
|
|
|
|
endfunction
|
2016-02-15 08:17:07 -07:00
|
|
|
command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo]])
|
2016-02-15 07:43:27 -07:00
|
|
|
feed(":Test2 <C-L>'<C-B>$put='<CR>")
|
|
|
|
|
|
|
|
source([[
|
|
|
|
function! CustomComplete3(lead, line, pos)
|
|
|
|
return ['Nこ', 'Nん', 'Nぶ']
|
|
|
|
endfunction
|
2016-02-15 08:17:07 -07:00
|
|
|
command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo]])
|
2016-02-15 07:43:27 -07:00
|
|
|
feed(":Test3 <C-L>'<C-B>$put='<CR>")
|
|
|
|
|
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2016-02-15 07:43:27 -07:00
|
|
|
Test1
|
|
|
|
Test2 あた
|
|
|
|
Test3 N]])
|
|
|
|
end)
|
2014-10-22 15:50:54 -07:00
|
|
|
end)
|