diff --git a/test/commands.vim b/test/commands.vim new file mode 100644 index 00000000..a56a437c --- /dev/null +++ b/test/commands.vim @@ -0,0 +1,32 @@ +let s:suite = themis#suite('parser') +let s:assert = themis#helper('assert') + +function! s:suite.internal() + VimShellCreate + + let $FOO = '' + call vimshell#execute('export FOO=foo') + call s:assert.equals($FOO, 'foo') + + " It contains space + let $FOO = '' + call vimshell#execute('export FOO="foo bar"') + call s:assert.equals($FOO, 'foo bar') + + let $FOO = '' + let $BAR = '' + call vimshell#execute('export FOO="foo" BAR="bar"') + call s:assert.equals($FOO, 'foo') + call s:assert.equals($BAR, 'bar') + + " Error pattern + let $FOO = '' + let $BAR = '' + call vimshell#execute('export FOO = "foo" BAR="bar"') + call s:assert.equals($FOO, '') + call s:assert.equals($BAR, '') + + VimShellCreate -toggle +endfunction + +" vim:foldmethod=marker:fen: diff --git a/test/config.vim b/test/config.vim new file mode 100644 index 00000000..adf5de19 --- /dev/null +++ b/test/config.vim @@ -0,0 +1,26 @@ +let s:suite = themis#suite('parser') +let s:assert = themis#helper('assert') + +function! s:suite.prompt() + let g:vimshell_prompt = "'% ' " + let g:vimshell_secondary_prompt = 'aaa ' + VimShellCreate -toggle + call s:assert.equals(vimshell#get_prompt(), "'% ' ") + call s:assert.equals(vimshell#get_secondary_prompt(), 'aaa ') + VimShellCreate -toggle + + let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")' + VimShellCreate -toggle + call s:assert.equals(vimshell#get_user_prompt(), + \ 'fnamemodify(getcwd(), ":~")') + VimShellCreate -toggle + let g:vimshell_user_prompt = "" +endfunction + +function! s:suite.options() + VimShellCreate -toggle -prompt=foo\ bar + call s:assert.equals(vimshell#get_prompt(), 'foo bar') + VimShellCreate -toggle +endfunction + +" vim:foldmethod=marker:fen: diff --git a/test/parser.vim b/test/parser.vim new file mode 100644 index 00000000..0a2be9f0 --- /dev/null +++ b/test/parser.vim @@ -0,0 +1,19 @@ +let s:suite = themis#suite('parser') +let s:assert = themis#helper('assert') + +function! s:suite.alias() + VimShellCreate + call vimshell#set_alias('l2', 'll') + call vimshell#set_alias('ll', 'ls -l') + call s:assert.equals( + \ vimshell#parser#parse_alias('l2'), 'ls -l') + VimShellCreate -toggle +endfunction + +function! s:suite.getopt() + call s:assert.equals(vimshell#parser#getopt(['foo', 'bar'], { + \ 'noarg' : ['--insert'], + \ }), [['foo', 'bar'], {}]) +endfunction + +" vim:foldmethod=marker:fen: diff --git a/vest/commands.vim b/vest/commands.vim deleted file mode 100644 index a03112a0..00000000 --- a/vest/commands.vim +++ /dev/null @@ -1,46 +0,0 @@ -" Tests for vimshell. - -scriptencoding utf-8 - -" Saving 'cpoptions' {{{ -let s:save_cpo = &cpo -set cpo&vim -" }}} - -Context Vesting.run() - It tests internal commands. - VimShellCreate - - let $FOO = '' - call vimshell#execute('export FOO=foo') - ShouldEqual $FOO, 'foo' - - " It contains space - let $FOO = '' - call vimshell#execute('export FOO="foo bar"') - ShouldEqual $FOO, 'foo bar' - - let $FOO = '' - let $BAR = '' - call vimshell#execute('export FOO="foo" BAR="bar"') - ShouldEqual $FOO, 'foo' - ShouldEqual $BAR, 'bar' - - " Error pattern - let $FOO = '' - let $BAR = '' - call vimshell#execute('export FOO = "foo" BAR="bar"') - ShouldEqual $FOO, '' - ShouldEqual $BAR, '' - - VimShellCreate -toggle - End -End - -Fin - -" Restore 'cpoptions' {{{ -let &cpo = s:save_cpo -" }}} - -" vim:foldmethod=marker:fen: diff --git a/vest/config.vim b/vest/config.vim deleted file mode 100644 index debbf167..00000000 --- a/vest/config.vim +++ /dev/null @@ -1,44 +0,0 @@ -" Tests for vimshell. - -scriptencoding utf-8 - -" Saving 'cpoptions' {{{ -let s:save_cpo = &cpo -set cpo&vim -" }}} - -Context Vesting.run() - It tests prompt. - let g:vimshell_prompt = "'% ' " - let g:vimshell_secondary_prompt = 'aaa ' - VimShellCreate -toggle - Should vimshell#get_prompt() ==# "'% ' " - Should vimshell#get_secondary_prompt() ==# 'aaa ' - VimShellCreate -toggle - - let g:vimshell_user_prompt = "3\ngetcwd()" - VimShellCreate -toggle - Should vimshell#get_user_prompt() ==# "3\ngetcwd()" - VimShellCreate -toggle - - let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")' - VimShellCreate -toggle - Should vimshell#get_user_prompt() ==# - \ 'fnamemodify(getcwd(), ":~")' - VimShellCreate -toggle - End - - It tests options. - VimShellCreate -toggle -prompt=foo\ bar - Should vimshell#get_prompt() ==# 'foo bar' - VimShellCreate -toggle - End -End - -Fin - -" Restore 'cpoptions' {{{ -let &cpo = s:save_cpo -" }}} - -" vim:foldmethod=marker:fen: diff --git a/vest/parser.vim b/vest/parser.vim deleted file mode 100644 index 91b4458a..00000000 --- a/vest/parser.vim +++ /dev/null @@ -1,32 +0,0 @@ -" Tests for vimshell. - -scriptencoding utf-8 - -" Saving 'cpoptions' {{{ -let s:save_cpo = &cpo -set cpo&vim -" }}} - -Context Vesting.run() - It tests aliases. - VimShellCreate - call vimshell#set_alias('l2', 'll') - call vimshell#set_alias('ll', 'ls -l') - ShouldEqual vimshell#parser#parse_alias('l2'), 'ls -l' - VimShellCreate -toggle - End - - It tests option parser. - ShouldEqual vimshell#parser#getopt(['foo', 'bar'], { - \ 'noarg' : ['--insert'], - \ }), [['foo', 'bar'], {}] - End -End - -Fin - -" Restore 'cpoptions' {{{ -let &cpo = s:save_cpo -" }}} - -" vim:foldmethod=marker:fen: