mirror of
https://github.com/inkarkat/vim-ingo-library.git
synced 2026-10-04 15:56:51 +02:00
20 lines
792 B
VimL
20 lines
792 B
VimL
" Test recursive mapping.
|
|
|
|
let s:expr = 'toupper(v:val)'
|
|
function! s:CreateData()
|
|
return ['a', 'b', [{'foo': 'bar', 'rec': ['e', 'ff']}, 'd']]
|
|
endfunction
|
|
|
|
call vimtest#StartTap()
|
|
call vimtap#Plan(4)
|
|
|
|
let s:data = s:CreateData()
|
|
call vimtap#Is(ingo#collections#recursive#map(s:data, s:expr), ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'in-place toupper')
|
|
call vimtap#Is(s:data, ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'in-place toupper modifies original')
|
|
|
|
let s:data = s:CreateData()
|
|
call vimtap#Is(ingo#collections#recursive#MapWithCopy(s:data, s:expr), ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'copied toupper')
|
|
call vimtap#Is(s:data, ['a', 'b', [{'foo': 'bar', 'rec': ['e', 'ff']}, 'd']], 'copied toupper keeps original')
|
|
|
|
call vimtest#Quit()
|