Mercurial > vim
comparison src/testdir/test_mapping.vim @ 17184:a5c3d374e1d3 v8.1.1591
patch 8.1.1591: on error garbage collection may free memory in use
commit https://github.com/vim/vim/commit/7d491c425334d9477637372a4ebec64c228c8430
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 25 06:28:02 2019 +0200
patch 8.1.1591: on error garbage collection may free memory in use
Problem: On error garbage collection may free memory in use.
Solution: Reset may_garbage_collect when evaluating expression mapping.
Add tests. (Ozaki Kiichi, closes #4579)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 25 Jun 2019 06:30:09 +0200 |
parents | fb7cf38a1c7a |
children | fceb0977275a |
comparison
equal
deleted
inserted
replaced
17183:694c578dedd2 | 17184:a5c3d374e1d3 |
---|---|
395 call assert_equal(['aaabbb', 'x', 'dddeee'], getline(1, '$')) | 395 call assert_equal(['aaabbb', 'x', 'dddeee'], getline(1, '$')) |
396 bwipe! | 396 bwipe! |
397 delfunc Select | 397 delfunc Select |
398 delfunc GetCommand | 398 delfunc GetCommand |
399 endfunc | 399 endfunc |
400 | |
401 func Test_error_in_map_expr() | |
402 if !has('terminal') || (has('win32') && has('gui_running')) | |
403 throw 'Skipped: cannot run Vim in a terminal window' | |
404 endif | |
405 | |
406 let lines =<< trim [CODE] | |
407 func Func() | |
408 " fail to create list | |
409 let x = [ | |
410 endfunc | |
411 nmap <expr> ! Func() | |
412 set updatetime=50 | |
413 [CODE] | |
414 call writefile(lines, 'Xtest.vim') | |
415 | |
416 let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8}) | |
417 let job = term_getjob(buf) | |
418 call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))}) | |
419 | |
420 " GC must not run during map-expr processing, which can make Vim crash. | |
421 call term_sendkeys(buf, '!') | |
422 call term_wait(buf, 100) | |
423 call term_sendkeys(buf, "\<CR>") | |
424 call term_wait(buf, 100) | |
425 call assert_equal('run', job_status(job)) | |
426 | |
427 call term_sendkeys(buf, ":qall!\<CR>") | |
428 call WaitFor({-> job_status(job) ==# 'dead'}) | |
429 if has('unix') | |
430 call assert_equal('', job_info(job).termsig) | |
431 endif | |
432 | |
433 call delete('Xtest.vim') | |
434 exe buf .. 'bwipe!' | |
435 endfunc |