summaryrefslogtreecommitdiff
path: root/src/testdir/test_system.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-08 13:26:03 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-08 13:26:03 +0100
commit12c4492dd35e0cd83c8816be2ec849b836109882 (patch)
tree95f4c3fe9930a7d42630659e7571175f5f2c2a22 /src/testdir/test_system.vim
parent7069bf18e1b1b7bc7640335e07d1022b5acc9048 (diff)
downloadvim-12c4492dd35e0cd83c8816be2ec849b836109882.zip
patch 8.0.0151: passing buffer content to system() is clumsy
Problem: To pass buffer content to system() and systemlist() one has to first create a string or list. Solution: Allow passing a buffer number. (LemonBoy, closes #1240)
Diffstat (limited to 'src/testdir/test_system.vim')
-rw-r--r--src/testdir/test_system.vim20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/testdir/test_system.vim b/src/testdir/test_system.vim
new file mode 100644
index 000000000..5e8d68b14
--- /dev/null
+++ b/src/testdir/test_system.vim
@@ -0,0 +1,20 @@
+" Tests for system() and systemlist()
+
+function! Test_System()
+ if !executable('echo') || !executable('cat') || !executable('wc')
+ return
+ endif
+ call assert_equal("123\n", system('echo 123'))
+ call assert_equal(['123'], systemlist('echo 123'))
+ call assert_equal('123', system('cat', '123'))
+ call assert_equal(['123'], systemlist('cat', '123'))
+ call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
+ new Xdummy
+ call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
+ call assert_equal("3\n", system('wc -l', bufnr('%')))
+ call assert_equal(['3'], systemlist('wc -l', bufnr('%')))
+ call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], systemlist('cat', bufnr('%')))
+ bwipe!
+
+ call assert_fails('call system("wc -l", 99999)', 'E86:')
+endfunction