Bram Moolenaar | 12c4492 | 2017-01-08 13:26:03 +0100 | [diff] [blame] | 1 | " Tests for system() and systemlist() |
| 2 | |
| 3 | function! Test_System() |
| 4 | if !executable('echo') || !executable('cat') || !executable('wc') |
| 5 | return |
| 6 | endif |
| 7 | call assert_equal("123\n", system('echo 123')) |
| 8 | call assert_equal(['123'], systemlist('echo 123')) |
| 9 | call assert_equal('123', system('cat', '123')) |
| 10 | call assert_equal(['123'], systemlist('cat', '123')) |
| 11 | call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) |
| 12 | new Xdummy |
| 13 | call setline(1, ['asdf', "pw\<NL>er", 'xxxx']) |
| 14 | call assert_equal("3\n", system('wc -l', bufnr('%'))) |
| 15 | call assert_equal(['3'], systemlist('wc -l', bufnr('%'))) |
| 16 | call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], systemlist('cat', bufnr('%'))) |
| 17 | bwipe! |
| 18 | |
| 19 | call assert_fails('call system("wc -l", 99999)', 'E86:') |
| 20 | endfunction |