summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_disassemble.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-06 21:06:30 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-06 21:06:30 +0200
commitb68b346e6db6d3f848e0a89905fcd7777b73c5d8 (patch)
tree566601b221f3af448beea080d27dc3772c027b9e /src/testdir/test_vim9_disassemble.vim
parent54ed0dff2913f9c973f6ab04b3c96372bdf07406 (diff)
downloadvim-git-8.2.0703.tar.gz
patch 8.2.0703: Vim9: closure cannot store value in outer contextv8.2.0703
Problem: Vim9: closure cannot store value in outer context. Solution: Make storing value in outer context work. Make :disassemble accept a function reference.
Diffstat (limited to 'src/testdir/test_vim9_disassemble.vim')
-rw-r--r--src/testdir/test_vim9_disassemble.vim36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 4e2caf09f..11703416d 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -291,6 +291,42 @@ def Test_disassemble_call()
res)
enddef
+def s:CreateRefs()
+ let local = 'a'
+ def Append(arg: string)
+ local ..= arg
+ enddef
+ g:Append = Append
+ def Get(): string
+ return local
+ enddef
+ g:Get = Get
+enddef
+
+def Test_disassemble_closure()
+ CreateRefs()
+ let res = execute('disass g:Append')
+ assert_match('<lambda>\d.*' ..
+ 'local ..= arg.*' ..
+ '\d LOADOUTER $0.*' ..
+ '\d LOAD arg\[-1\].*' ..
+ '\d CONCAT.*' ..
+ '\d STOREOUTER $0.*' ..
+ '\d PUSHNR 0.*' ..
+ '\d RETURN.*',
+ res)
+
+ res = execute('disass g:Get')
+ assert_match('<lambda>\d.*' ..
+ 'return local.*' ..
+ '\d LOADOUTER $0.*' ..
+ '\d RETURN.*',
+ res)
+
+ unlet g:Append
+ unlet g:Get
+enddef
+
def EchoArg(arg: string): string
return arg