From ce6c2d8aba256aa75061d236593eb44027d6b669 Mon Sep 17 00:00:00 2001 From: itchyny Date: Mon, 21 Mar 2016 16:41:40 +0900 Subject: [PATCH] add more tests for s:expand: short array --- test/expand.vim | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/expand.vim b/test/expand.vim index 84b2e8e..42647ab 100644 --- a/test/expand.vim +++ b/test/expand.vim @@ -171,6 +171,58 @@ function! s:suite.custom_type_void_string_array_2() delfunction Custom endfunction +function! s:suite.custom_one() + function! Custom() + return [ 'left' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], [0, 1, 2, 3]]) + call s:assert.equals(SID('expand')([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], [0, 1]]) + delfunction Custom +endfunction + +function! s:suite.custom_type_one() + function! Custom() + return [ 'left' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], [0, 1, 2, 3]]) + call s:assert.equals(SID('expand')([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], [0, 1]]) + delfunction Custom +endfunction + +function! s:suite.custom_two() + function! Custom() + return [ 'left', 'middle'] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle'], ['modified']], [[0, 0], [1, 1], [0]], [0, 1, 2, 3]]) + call s:assert.equals(SID('expand')([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'modified']], [[0, 0, 1, 1, 0]], [0, 1]]) + delfunction Custom +endfunction + +function! s:suite.custom_type_two() + function! Custom() + return [ 'left', 'middle' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['middle'], ['modified']], [[0, 0], [1], [1], [0]], [0, 1, 'custom', 2, 3]]) + call s:assert.equals(SID('expand')([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['middle'], ['modified']], [[0, 0, 1], [1], [0]], [0, 'custom', 0, 1]]) + delfunction Custom +endfunction + function! s:suite.custom_mixed() function! Custom() return ['left', { 'custom': 24 }, [function('tr')]]