From 5f50a0d0fac1bcfa3cfd082d93e5cbceee3ac752 Mon Sep 17 00:00:00 2001 From: itchyny Date: Mon, 21 Mar 2016 22:34:16 +0900 Subject: [PATCH] add more tests for s:expand --- test/expand.vim | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/expand.vim b/test/expand.vim index 7b81d90..79201e1 100644 --- a/test/expand.vim +++ b/test/expand.vim @@ -554,3 +554,55 @@ function! s:suite.duplicated_type_both_nil() \ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], [0, 'custom', 0, 1]]) delfunction Custom endfunction + +function! s:suite.duplicated_both_nil_left_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['custom', 'custom'], ['modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], [0, 1, 2]]) + call s:assert.equals(SID('expand')([['custom', 'custom', 'modified']]), + \ [[['y0', 'y1', 'y0', 'y1', 'modified']], [[1, 1, 1, 1, 0]], [0, 1]]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_both_nil_left_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['custom', 'custom'], ['modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', 1, 2]]) + call s:assert.equals(SID('expand')([['custom', 'custom', 'modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', 0, 1]]) + delfunction Custom +endfunction + +function! s:suite.duplicated_both_nil_right_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['filename'], ['custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], [0, 1, 2]]) + call s:assert.equals(SID('expand')([['filename', 'custom', 'custom']]), + \ [[['filename', 'y0', 'y1', 'y0', 'y1']], [[0, 1, 1, 1, 1]], [0, 1]]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_both_nil_right_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(SID('expand')([['filename'], ['custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], [0, 'custom', 2]]) + call s:assert.equals(SID('expand')([['filename', 'custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], [0, 'custom', 1]]) + delfunction Custom +endfunction