1" Tests for various Ex commands. 2 3source check.vim 4 5func Test_ex_delete() 6 new 7 call setline(1, ['a', 'b', 'c']) 8 2 9 " :dl is :delete with the "l" flag, not :dlist 10 .dl 11 call assert_equal(['a', 'c'], getline(1, 2)) 12endfunc 13 14func Test_range_error() 15 call assert_fails(':.echo 1', 'E481:') 16 call assert_fails(':$echo 1', 'E481:') 17 call assert_fails(':1,2echo 1', 'E481:') 18 call assert_fails(':+1echo 1', 'E481:') 19 call assert_fails(':/1/echo 1', 'E481:') 20 call assert_fails(':\/echo 1', 'E481:') 21 normal vv 22 call assert_fails(":'<,'>echo 1", 'E481:') 23 call assert_fails(":\\xcenter", 'E10:') 24endfunc 25 26func Test_buffers_lastused() 27 call test_settime(localtime() - 2000) " middle 28 edit bufa 29 enew 30 call test_settime(localtime() - 10) " newest 31 edit bufb 32 enew 33 call test_settime(1550010000) " oldest 34 edit bufc 35 enew 36 call test_settime(0) 37 enew 38 39 let ls = split(execute('buffers t', 'silent!'), '\n') 40 let bufs = ls->map({i,v->split(v, '"\s*')[1:2]}) 41 call assert_equal(['bufb', 'bufa', 'bufc'], bufs[1:]->map({i,v->v[0]})) 42 call assert_match('1[0-3] seconds ago', bufs[1][1]) 43 call assert_match('\d\d:\d\d:\d\d', bufs[2][1]) 44 call assert_match('2019/02/1\d \d\d:\d\d:00', bufs[3][1]) 45 46 bwipeout bufa 47 bwipeout bufb 48 bwipeout bufc 49endfunc 50 51" Test for the :copy command 52func Test_copy() 53 new 54 55 call setline(1, ['L1', 'L2', 'L3', 'L4']) 56 " copy lines in a range to inside the range 57 1,3copy 2 58 call assert_equal(['L1', 'L2', 'L1', 'L2', 'L3', 'L3', 'L4'], getline(1, 7)) 59 60 " Specifying a count before using : to run an ex-command 61 exe "normal! gg4:yank\<CR>" 62 call assert_equal("L1\nL2\nL1\nL2\n", @") 63 64 close! 65endfunc 66 67" Test for the :file command 68func Test_file_cmd() 69 call assert_fails('3file', 'E474:') 70 call assert_fails('0,0file', 'E474:') 71 call assert_fails('0file abc', 'E474:') 72 if !has('win32') 73 " Change the name of the buffer to the same name 74 new Xfile1 75 file Xfile1 76 call assert_equal('Xfile1', @%) 77 call assert_equal('Xfile1', @#) 78 bw! 79 endif 80endfunc 81 82" Test for the :drop command 83func Test_drop_cmd() 84 call writefile(['L1', 'L2'], 'Xfile') 85 enew | only 86 drop Xfile 87 call assert_equal('L2', getline(2)) 88 " Test for switching to an existing window 89 below new 90 drop Xfile 91 call assert_equal(1, winnr()) 92 " Test for splitting the current window 93 enew | only 94 set modified 95 drop Xfile 96 call assert_equal(2, winnr('$')) 97 " Check for setting the argument list 98 call assert_equal(['Xfile'], argv()) 99 enew | only! 100 call delete('Xfile') 101endfunc 102 103" Test for the :append command 104func Test_append_cmd() 105 new 106 call setline(1, [' L1']) 107 call feedkeys(":append\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 108 call assert_equal([' L1', ' L2', ' L3'], getline(1, '$')) 109 %delete _ 110 " append after a specific line 111 call setline(1, [' L1', ' L2', ' L3']) 112 call feedkeys(":2append\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 113 call assert_equal([' L1', ' L2', ' L4', ' L5', ' L3'], getline(1, '$')) 114 %delete _ 115 " append with toggling 'autoindent' 116 call setline(1, [' L1']) 117 call feedkeys(":append!\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 118 call assert_equal([' L1', ' L2', ' L3'], getline(1, '$')) 119 call assert_false(&autoindent) 120 %delete _ 121 " append with 'autoindent' set and toggling 'autoindent' 122 set autoindent 123 call setline(1, [' L1']) 124 call feedkeys(":append!\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 125 call assert_equal([' L1', ' L2', ' L3'], getline(1, '$')) 126 call assert_true(&autoindent) 127 set autoindent& 128 close! 129endfunc 130 131" Test for the :insert command 132func Test_insert_cmd() 133 new 134 call setline(1, [' L1']) 135 call feedkeys(":insert\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 136 call assert_equal([' L2', ' L3', ' L1'], getline(1, '$')) 137 %delete _ 138 " insert before a specific line 139 call setline(1, [' L1', ' L2', ' L3']) 140 call feedkeys(":2insert\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 141 call assert_equal([' L1', ' L4', ' L5', ' L2', ' L3'], getline(1, '$')) 142 %delete _ 143 " insert with toggling 'autoindent' 144 call setline(1, [' L1']) 145 call feedkeys(":insert!\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 146 call assert_equal([' L2', ' L3', ' L1'], getline(1, '$')) 147 call assert_false(&autoindent) 148 %delete _ 149 " insert with 'autoindent' set and toggling 'autoindent' 150 set autoindent 151 call setline(1, [' L1']) 152 call feedkeys(":insert!\<CR> L2\<CR> L3\<CR>.\<CR>", 'xt') 153 call assert_equal([' L2', ' L3', ' L1'], getline(1, '$')) 154 call assert_true(&autoindent) 155 set autoindent& 156 close! 157endfunc 158 159" Test for the :change command 160func Test_change_cmd() 161 new 162 call setline(1, [' L1', 'L2', 'L3']) 163 call feedkeys(":change\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 164 call assert_equal([' L4', ' L5', 'L2', 'L3'], getline(1, '$')) 165 %delete _ 166 " change a specific line 167 call setline(1, [' L1', ' L2', ' L3']) 168 call feedkeys(":2change\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 169 call assert_equal([' L1', ' L4', ' L5', ' L3'], getline(1, '$')) 170 %delete _ 171 " change with toggling 'autoindent' 172 call setline(1, [' L1', 'L2', 'L3']) 173 call feedkeys(":change!\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 174 call assert_equal([' L4', ' L5', 'L2', 'L3'], getline(1, '$')) 175 call assert_false(&autoindent) 176 %delete _ 177 " change with 'autoindent' set and toggling 'autoindent' 178 set autoindent 179 call setline(1, [' L1', 'L2', 'L3']) 180 call feedkeys(":change!\<CR> L4\<CR> L5\<CR>.\<CR>", 'xt') 181 call assert_equal([' L4', ' L5', 'L2', 'L3'], getline(1, '$')) 182 call assert_true(&autoindent) 183 set autoindent& 184 close! 185endfunc 186 187" Test for the :language command 188func Test_language_cmd() 189 CheckFeature multi_lang 190 191 call assert_fails('language ctype non_existing_lang', 'E197:') 192 call assert_fails('language time non_existing_lang', 'E197:') 193endfunc 194 195" Test for the :confirm command dialog 196func Test_confirm_cmd() 197 CheckNotGui 198 CheckRunVimInTerminal 199 200 call writefile(['foo1'], 'Xfoo') 201 call writefile(['bar1'], 'Xbar') 202 203 " Test for saving all the modified buffers 204 let lines =<< trim END 205 set nomore 206 new Xfoo 207 call setline(1, 'foo2') 208 new Xbar 209 call setline(1, 'bar2') 210 wincmd b 211 END 212 call writefile(lines, 'Xscript') 213 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 214 call term_sendkeys(buf, ":confirm qall\n") 215 call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) 216 call term_sendkeys(buf, "A") 217 call StopVimInTerminal(buf) 218 219 call assert_equal(['foo2'], readfile('Xfoo')) 220 call assert_equal(['bar2'], readfile('Xbar')) 221 222 " Test for discarding all the changes to modified buffers 223 let lines =<< trim END 224 set nomore 225 new Xfoo 226 call setline(1, 'foo3') 227 new Xbar 228 call setline(1, 'bar3') 229 wincmd b 230 END 231 call writefile(lines, 'Xscript') 232 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 233 call term_sendkeys(buf, ":confirm qall\n") 234 call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) 235 call term_sendkeys(buf, "D") 236 call StopVimInTerminal(buf) 237 238 call assert_equal(['foo2'], readfile('Xfoo')) 239 call assert_equal(['bar2'], readfile('Xbar')) 240 241 " Test for saving and discarding changes to some buffers 242 let lines =<< trim END 243 set nomore 244 new Xfoo 245 call setline(1, 'foo4') 246 new Xbar 247 call setline(1, 'bar4') 248 wincmd b 249 END 250 call writefile(lines, 'Xscript') 251 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 252 call term_sendkeys(buf, ":confirm qall\n") 253 call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) 254 call term_sendkeys(buf, "N") 255 call WaitForAssert({-> assert_match('\[Y\]es, (N)o, (C)ancel: ', term_getline(buf, 20))}, 1000) 256 call term_sendkeys(buf, "Y") 257 call StopVimInTerminal(buf) 258 259 call assert_equal(['foo4'], readfile('Xfoo')) 260 call assert_equal(['bar2'], readfile('Xbar')) 261 262 call delete('Xscript') 263 call delete('Xfoo') 264 call delete('Xbar') 265endfunc 266 267func Test_confirm_cmd_cancel() 268 CheckNotGui 269 CheckRunVimInTerminal 270 271 " Test for closing a window with a modified buffer 272 let lines =<< trim END 273 set nomore 274 new 275 call setline(1, 'abc') 276 END 277 call writefile(lines, 'Xscript') 278 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 279 call term_sendkeys(buf, ":confirm close\n") 280 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', 281 \ term_getline(buf, 20))}, 1000) 282 call term_sendkeys(buf, "C") 283 call WaitForAssert({-> assert_equal('', term_getline(buf, 20))}, 1000) 284 call term_sendkeys(buf, ":confirm close\n") 285 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', 286 \ term_getline(buf, 20))}, 1000) 287 call term_sendkeys(buf, "N") 288 call WaitForAssert({-> assert_match('^ *0,0-1 All$', 289 \ term_getline(buf, 20))}, 1000) 290 call StopVimInTerminal(buf) 291 call delete('Xscript') 292endfunc 293 294" The ":confirm" prompt was sometimes used with the terminal in cooked mode. 295" This test verifies that a "\<CR>" character is NOT required to respond to a 296" prompt from the ":conf q" and ":conf wq" commands. 297func Test_confirm_q_wq() 298 CheckNotGui 299 CheckRunVimInTerminal 300 301 call writefile(['foo'], 'Xfoo') 302 303 let lines =<< trim END 304 set hidden nomore 305 call setline(1, 'abc') 306 edit Xfoo 307 END 308 call writefile(lines, 'Xscript') 309 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 310 call term_sendkeys(buf, ":confirm q\n") 311 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', 312 \ term_getline(buf, 20))}, 1000) 313 call term_sendkeys(buf, 'C') 314 call WaitForAssert({-> assert_notmatch('^\[Y\]es, (N)o, (C)ancel: C*$', 315 \ term_getline(buf, 20))}, 1000) 316 317 call term_sendkeys(buf, ":edit Xfoo\n") 318 call term_sendkeys(buf, ":confirm wq\n") 319 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', 320 \ term_getline(buf, 20))}, 1000) 321 call term_sendkeys(buf, 'C') 322 call WaitForAssert({-> assert_notmatch('^\[Y\]es, (N)o, (C)ancel: C*$', 323 \ term_getline(buf, 20))}, 1000) 324 call StopVimInTerminal(buf) 325 326 call delete('Xscript') 327 call delete('Xfoo') 328endfunc 329 330func Test_confirm_write_ro() 331 CheckNotGui 332 CheckRunVimInTerminal 333 334 call writefile(['foo'], 'Xconfirm_write_ro') 335 let lines =<< trim END 336 set nobackup ff=unix cmdheight=2 337 edit Xconfirm_write_ro 338 norm Abar 339 END 340 call writefile(lines, 'Xscript') 341 let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) 342 343 " Try to write with 'ro' option. 344 call term_sendkeys(buf, ":set ro | confirm w\n") 345 call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$", 346 \ term_getline(buf, 18))}, 1000) 347 call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$', 348 \ term_getline(buf, 19))}, 1000) 349 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000) 350 call term_sendkeys(buf, 'N') 351 call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 19))}, 1000) 352 call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000) 353 call assert_equal(['foo'], readfile('Xconfirm_write_ro')) 354 355 call term_sendkeys(buf, ":confirm w\n") 356 call WaitForAssert({-> assert_match("^'readonly' option is set for \"Xconfirm_write_ro\"\. *$", 357 \ term_getline(buf, 18))}, 1000) 358 call WaitForAssert({-> assert_match('^Do you wish to write anyway? *$', 359 \ term_getline(buf, 19))}, 1000) 360 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000) 361 call term_sendkeys(buf, 'Y') 362 call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 7B written$', 363 \ term_getline(buf, 19))}, 1000) 364 call assert_equal(['foobar'], readfile('Xconfirm_write_ro')) 365 366 " Try to write with read-only file permissions. 367 call setfperm('Xconfirm_write_ro', 'r--r--r--') 368 call term_sendkeys(buf, ":set noro | undo | confirm w\n") 369 call WaitForAssert({-> assert_match("^File permissions of \"Xconfirm_write_ro\" are read-only\. *$", 370 \ term_getline(buf, 17))}, 1000) 371 call WaitForAssert({-> assert_match('^It may still be possible to write it\. *$', 372 \ term_getline(buf, 18))}, 1000) 373 call WaitForAssert({-> assert_match('^Do you wish to try? *$', term_getline(buf, 19))}, 1000) 374 call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', term_getline(buf, 20))}, 1000) 375 call term_sendkeys(buf, 'Y') 376 call WaitForAssert({-> assert_match('^"Xconfirm_write_ro" 1L, 4B written$', 377 \ term_getline(buf, 19))}, 1000) 378 call assert_equal(['foo'], readfile('Xconfirm_write_ro')) 379 380 call StopVimInTerminal(buf) 381 call delete('Xscript') 382 call delete('Xconfirm_write_ro') 383endfunc 384 385" Test for the :print command 386func Test_print_cmd() 387 call assert_fails('print', 'E749:') 388endfunc 389 390" Test for the :winsize command 391func Test_winsize_cmd() 392 call assert_fails('winsize 1', 'E465:') 393 call assert_fails('winsize 1 x', 'E465:') 394 call assert_fails('win_getid(1)', 'E475: Invalid argument: _getid(1)') 395 " Actually changing the window size would be flaky. 396endfunc 397 398" Test for the :redir command 399" NOTE: if you run tests as root this will fail. Don't run tests as root! 400func Test_redir_cmd() 401 call assert_fails('redir @@', 'E475:') 402 call assert_fails('redir abc', 'E475:') 403 call assert_fails('redir => 1abc', 'E474:') 404 call assert_fails('redir => a b', 'E488:') 405 call assert_fails('redir => abc[1]', 'E121:') 406 let b = 0zFF 407 call assert_fails('redir =>> b', 'E734:') 408 unlet b 409 410 if has('unix') 411 " Redirecting to a directory name 412 call mkdir('Xdir') 413 call assert_fails('redir > Xdir', 'E17:') 414 call delete('Xdir', 'd') 415 endif 416 417 " Test for redirecting to a register 418 redir @q> | echon 'clean ' | redir END 419 redir @q>> | echon 'water' | redir END 420 call assert_equal('clean water', @q) 421 422 " Test for redirecting to a variable 423 redir => color | echon 'blue ' | redir END 424 redir =>> color | echon 'sky' | redir END 425 call assert_equal('blue sky', color) 426endfunc 427 428func Test_redir_cmd_readonly() 429 CheckNotRoot 430 431 " Redirecting to a read-only file 432 call writefile([], 'Xfile') 433 call setfperm('Xfile', 'r--r--r--') 434 call assert_fails('redir! > Xfile', 'E190:') 435 call delete('Xfile') 436endfunc 437 438" Test for the :filetype command 439func Test_filetype_cmd() 440 call assert_fails('filetype abc', 'E475:') 441endfunc 442 443" Test for the :mode command 444func Test_mode_cmd() 445 call assert_fails('mode abc', 'E359:') 446endfunc 447 448" Test for the :sleep command 449func Test_sleep_cmd() 450 call assert_fails('sleep x', 'E475:') 451endfunc 452 453" Test for the :read command 454func Test_read_cmd() 455 call writefile(['one'], 'Xfile') 456 new 457 call assert_fails('read', 'E32:') 458 edit Xfile 459 read 460 call assert_equal(['one', 'one'], getline(1, '$')) 461 close! 462 new 463 read Xfile 464 call assert_equal(['', 'one'], getline(1, '$')) 465 call deletebufline('', 1, '$') 466 call feedkeys("Qr Xfile\<CR>visual\<CR>", 'xt') 467 call assert_equal(['one'], getline(1, '$')) 468 close! 469 call delete('Xfile') 470endfunc 471 472" Test for running Ex commands when text is locked. 473" <C-\>e in the command line is used to lock the text 474func Test_run_excmd_with_text_locked() 475 " :quit 476 let cmd = ":\<C-\>eexecute('quit')\<CR>\<C-C>" 477 call assert_fails("call feedkeys(cmd, 'xt')", 'E565:') 478 479 " :qall 480 let cmd = ":\<C-\>eexecute('qall')\<CR>\<C-C>" 481 call assert_fails("call feedkeys(cmd, 'xt')", 'E565:') 482 483 " :exit 484 let cmd = ":\<C-\>eexecute('exit')\<CR>\<C-C>" 485 call assert_fails("call feedkeys(cmd, 'xt')", 'E565:') 486 487 " :close - should be ignored 488 new 489 let cmd = ":\<C-\>eexecute('close')\<CR>\<C-C>" 490 call assert_equal(2, winnr('$')) 491 close 492 493 call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:') 494 495 " :tabfirst 496 tabnew 497 call assert_fails("call feedkeys(\":\<C-R>=execute('tabfirst')\<CR>\", 'xt')", 'E565:') 498 tabclose 499endfunc 500 501" Test for the :verbose command 502func Test_verbose_cmd() 503 call assert_equal([' verbose=1'], split(execute('verbose set vbs'), "\n")) 504 call assert_equal([' verbose=0'], split(execute('0verbose set vbs'), "\n")) 505 let l = execute("4verbose set verbose | set verbose") 506 call assert_equal([' verbose=4', ' verbose=0'], split(l, "\n")) 507endfunc 508 509" Test for the :delete command and the related abbreviated commands 510func Test_excmd_delete() 511 new 512 call setline(1, ['foo', "\tbar"]) 513 call assert_equal(['^Ibar$'], split(execute('dl'), "\n")) 514 call setline(1, ['foo', "\tbar"]) 515 call assert_equal(['^Ibar$'], split(execute('dell'), "\n")) 516 call setline(1, ['foo', "\tbar"]) 517 call assert_equal(['^Ibar$'], split(execute('delel'), "\n")) 518 call setline(1, ['foo', "\tbar"]) 519 call assert_equal(['^Ibar$'], split(execute('deletl'), "\n")) 520 call setline(1, ['foo', "\tbar"]) 521 call assert_equal(['^Ibar$'], split(execute('deletel'), "\n")) 522 call setline(1, ['foo', "\tbar"]) 523 call assert_equal([' bar'], split(execute('dp'), "\n")) 524 call setline(1, ['foo', "\tbar"]) 525 call assert_equal([' bar'], split(execute('dep'), "\n")) 526 call setline(1, ['foo', "\tbar"]) 527 call assert_equal([' bar'], split(execute('delp'), "\n")) 528 call setline(1, ['foo', "\tbar"]) 529 call assert_equal([' bar'], split(execute('delep'), "\n")) 530 call setline(1, ['foo', "\tbar"]) 531 call assert_equal([' bar'], split(execute('deletp'), "\n")) 532 call setline(1, ['foo', "\tbar"]) 533 call assert_equal([' bar'], split(execute('deletep'), "\n")) 534 close! 535endfunc 536 537" Test for commands that are blocked in a sandbox 538func Sandbox_tests() 539 call assert_fails("call histadd(':', 'ls')", 'E48:') 540 call assert_fails("call mkdir('Xdir')", 'E48:') 541 call assert_fails("call rename('a', 'b')", 'E48:') 542 call assert_fails("call setbufvar(1, 'myvar', 1)", 'E48:') 543 call assert_fails("call settabvar(1, 'myvar', 1)", 'E48:') 544 call assert_fails("call settabwinvar(1, 1, 'myvar', 1)", 'E48:') 545 call assert_fails("call setwinvar(1, 'myvar', 1)", 'E48:') 546 call assert_fails("call timer_start(100, '')", 'E48:') 547 if has('channel') 548 call assert_fails("call prompt_setcallback(1, '')", 'E48:') 549 call assert_fails("call prompt_setinterrupt(1, '')", 'E48:') 550 call assert_fails("call prompt_setprompt(1, '')", 'E48:') 551 endif 552 call assert_fails("let $TESTVAR=1", 'E48:') 553 call assert_fails("call feedkeys('ivim')", 'E48:') 554 call assert_fails("source! Xfile", 'E48:') 555 call assert_fails("call delete('Xfile')", 'E48:') 556 call assert_fails("call writefile([], 'Xfile')", 'E48:') 557 call assert_fails('!ls', 'E48:') 558 call assert_fails('shell', 'E48:') 559 call assert_fails('stop', 'E48:') 560 call assert_fails('exe "normal \<C-Z>"', 'E48:') 561 set insertmode 562 call assert_fails('call feedkeys("\<C-Z>", "xt")', 'E48:') 563 set insertmode& 564 call assert_fails('suspend', 'E48:') 565 call assert_fails('call system("ls")', 'E48:') 566 call assert_fails('call systemlist("ls")', 'E48:') 567 if has('clientserver') 568 call assert_fails('let s=remote_expr("gvim", "2+2")', 'E48:') 569 if !has('win32') 570 " remote_foreground() doesn't thrown an error message on MS-Windows 571 call assert_fails('call remote_foreground("gvim")', 'E48:') 572 endif 573 call assert_fails('let s=remote_peek("gvim")', 'E48:') 574 call assert_fails('let s=remote_read("gvim")', 'E48:') 575 call assert_fails('let s=remote_send("gvim", "abc")', 'E48:') 576 call assert_fails('let s=server2client("gvim", "abc")', 'E48:') 577 endif 578 if has('terminal') 579 call assert_fails('terminal', 'E48:') 580 call assert_fails('call term_start("vim")', 'E48:') 581 call assert_fails('call term_dumpwrite(1, "Xfile")', 'E48:') 582 endif 583 if has('channel') 584 call assert_fails("call ch_logfile('chlog')", 'E48:') 585 call assert_fails("call ch_open('localhost:8765')", 'E48:') 586 endif 587 if has('job') 588 call assert_fails("call job_start('vim')", 'E48:') 589 endif 590 if has('unix') && has('libcall') 591 call assert_fails("echo libcall('libc.so', 'getenv', 'HOME')", 'E48:') 592 endif 593 if has('unix') 594 call assert_fails('cd `pwd`', 'E48:') 595 endif 596 " some options cannot be changed in a sandbox 597 call assert_fails('set exrc', 'E48:') 598 call assert_fails('set cdpath', 'E48:') 599 if has('xim') && has('gui_gtk') 600 call assert_fails('set imstyle', 'E48:') 601 endif 602endfunc 603 604func Test_sandbox() 605 sandbox call Sandbox_tests() 606endfunc 607 608func Test_command_not_implemented_E319() 609 if !has('mzscheme') 610 call assert_fails('mzscheme', 'E319:') 611 endif 612endfunc 613 614" vim: shiftwidth=2 sts=2 expandtab 615