Refactor code for testing

This commit is contained in:
aiya000 2015-12-23 22:30:34 +09:00
parent ca8f61644c
commit afc8d860f6
3 changed files with 24 additions and 3 deletions

View File

@ -36,9 +36,12 @@ nnoremap <silent> <Plug>(repl-run) :<C-u>call repl#run_repl()<CR>
"-------------------"
" Define default keymappings
if !exists('g:repl_no_default_keymappings') || !g:repl_no_default_keymappings
nmap <space>i <Plug>(repl-run)
endif
function! s:define_default_keymappings()
if !exists('g:repl_no_default_keymappings') || !g:repl_no_default_keymappings
nmap <leader>i <Plug>(repl-run)
endif
endfunction
call s:define_default_keymappings()
"-------------------"
let &cpo = s:save_cpo

View File

@ -8,5 +8,6 @@ call themis#option('runtimepath', expand('~/.vim/bundle/vimshell.vim'))
" Util Functions
function! UnletReplUserVariables() abort
unlet! g:repl_filetype_repl
unlet! g:repl_no_default_keymappings
unlet! g:repl_split_command
endfunction

View File

@ -1,5 +1,6 @@
let s:suite = themis#suite('variable')
let s:assert = themis#helper('assert')
let s:scope = themis#helper('scope')
function! s:suite.after_each()
call UnletReplUserVariables()
@ -30,3 +31,19 @@ function! s:suite.g_repl_filetype_repl_is_valid()
call s:assert.equals(l:filetype_repl['repl'], l:REPL_NAME)
call s:assert.equals(l:filetype_repl['opt'], l:REPL_OPT)
endfunction
"function! s:suite.g_repl_no_default_keymappings_is_valid_if_disabled()
" " Case: g:repl_no_default_keymappings is undefined
" let s:funcs = s:scope.funcs('plugin/repl.vim')
" call s:funcs.define_default_keymappings()
" call s:assert.true(hasmapto("\i", 'n'))
" nunmap <leader>i
"endfunction
"
"function! s:suite.g_repl_no_default_keymappings_is_valid_if_enabled()
" " Case: g:repl_no_default_keymappings is defined to 1
" let g:repl_no_default_keymappings = 1
" let s:funcs = s:scope.funcs('plugin/repl.vim')
" call s:funcs.define_default_keymappings()
" call s:assert.false(hasmapto("\i", 'n'))
"endfunction