comparison src/testdir/test_expr.vim @ 10245:d76ccdacb41e v8.0.0020

commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 2 16:51:57 2016 +0200 patch 8.0.0020 Problem: The regexp engines are not reentrant. Solution: Add regexec_T and save/restore the state when needed.
author Christian Brabandt <cb@256bit.org>
date Sun, 02 Oct 2016 17:00:05 +0200
parents 9415453b7bbd
children 053d4ad16f37
comparison
equal deleted inserted replaced
10244:876fbdd84e52 10245:d76ccdacb41e
403 403
404 call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)', 404 call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)',
405 \ {-> submatch(2) . submatch(3) . submatch(1)}, '')) 405 \ {-> submatch(2) . submatch(3) . submatch(1)}, ''))
406 406
407 func Recurse() 407 func Recurse()
408 return substitute('yyy', 'y*', {-> g:val}, '') 408 return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '')
409 endfunc 409 endfunc
410 call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'}, '')) 410 " recursive call works
411 call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, ''))
411 endfunc 412 endfunc
412 413
413 func Test_invalid_submatch() 414 func Test_invalid_submatch()
414 " This was causing invalid memory access in Vim-7.4.2232 and older 415 " This was causing invalid memory access in Vim-7.4.2232 and older
415 call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:') 416 call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:')