comparison src/testdir/test_diffmode.vim @ 26743:c2c40cefc17b v8.2.3900

patch 8.2.3900: it is not easy to use a script-local function for an option Commit: https://github.com/vim/vim/commit/8bb65f230d3025037f34021a72616038da0601ee Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Dec 26 10:51:39 2021 +0000 patch 8.2.3900: it is not easy to use a script-local function for an option Problem: It is not easy to use a script-local function for an option. Solution: recognize s: and <SID> at the start of the expression. (Yegappan Lakshmanan, closes #9401)
author Bram Moolenaar <Bram@vim.org>
date Sun, 26 Dec 2021 12:00:04 +0100
parents 485c7c4afeb7
children 83a99f08d1e8
comparison
equal deleted inserted replaced
26742:00732e690ee8 26743:c2c40cefc17b
679 679
680 " Try using a non-existing function for 'diffexpr'. 680 " Try using a non-existing function for 'diffexpr'.
681 set diffexpr=NewDiffFunc() 681 set diffexpr=NewDiffFunc()
682 call assert_fails('windo diffthis', ['E117:', 'E97:']) 682 call assert_fails('windo diffthis', ['E117:', 'E97:'])
683 diffoff! 683 diffoff!
684
685 " Using a script-local function
686 func s:NewDiffExpr()
687 endfunc
688 set diffexpr=s:NewDiffExpr()
689 call assert_equal(expand('<SID>') .. 'NewDiffExpr()', &diffexpr)
690 set diffexpr=<SID>NewDiffExpr()
691 call assert_equal(expand('<SID>') .. 'NewDiffExpr()', &diffexpr)
692
684 %bwipe! 693 %bwipe!
685 set diffexpr& diffopt& 694 set diffexpr& diffopt&
695 delfunc DiffExpr
696 delfunc s:NewDiffExpr
686 endfunc 697 endfunc
687 698
688 func Test_diffpatch() 699 func Test_diffpatch()
689 " The patch program on MS-Windows may fail or hang. 700 " The patch program on MS-Windows may fail or hang.
690 CheckExecutable patch 701 CheckExecutable patch
1214 call assert_equal('output file', getline(1)) 1225 call assert_equal('output file', getline(1))
1215 call assert_equal('Xinput.new', bufname()) 1226 call assert_equal('Xinput.new', bufname())
1216 call assert_equal(2, winnr('$')) 1227 call assert_equal(2, winnr('$'))
1217 call assert_true(&diff) 1228 call assert_true(&diff)
1218 1229
1230 " Using a script-local function
1231 func s:NewPatchExpr()
1232 endfunc
1233 set patchexpr=s:NewPatchExpr()
1234 call assert_equal(expand('<SID>') .. 'NewPatchExpr()', &patchexpr)
1235 set patchexpr=<SID>NewPatchExpr()
1236 call assert_equal(expand('<SID>') .. 'NewPatchExpr()', &patchexpr)
1237
1219 call delete('Xinput') 1238 call delete('Xinput')
1220 call delete('Xdiff') 1239 call delete('Xdiff')
1221 set patchexpr& 1240 set patchexpr&
1222 delfunc TPatch 1241 delfunc TPatch
1242 delfunc s:NewPatchExpr
1223 %bwipe! 1243 %bwipe!
1224 endfunc 1244 endfunc
1225 1245
1226 func Test_diff_rnu() 1246 func Test_diff_rnu()
1227 CheckScreendump 1247 CheckScreendump