changeset 33191:4efe5f797919 v9.0.1875

patch 9.0.1875: Vim9: improve test for disassemble + static Commit: https://github.com/vim/vim/commit/28a60f898d5cd7023596b0e96a081b1573edc807 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Sep 5 20:42:18 2023 +0200 patch 9.0.1875: Vim9: improve test for disassemble + static Problem: Vim9: improve test for disassemble + static Solution: Add a Vim9 script disassemble test for an interface with static members closes: #13037 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Tue, 05 Sep 2023 20:45:05 +0200
parents ab6ab80cca76
children efd072489401
files src/testdir/test_vim9_disassemble.vim src/version.c
diffstat 2 files changed, 86 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -3046,4 +3046,88 @@ def Test_disassemble_class_function()
   unlet g:instr
 enddef
 
+" Disassemble instructions for using an interface with static and regular member
+" variables.
+def Test_disassemble_interface_static_member()
+  var lines =<< trim END
+    vim9script
+    interface I
+      public static s_var: number
+      public this.o_var: number
+      public static s_var2: number
+      public this.o_var2: number
+    endinterface
+
+    class C implements I
+      public static s_var: number
+      public this.o_var: number
+      public static s_var2: number
+      public this.o_var2: number
+    endclass
+
+    def F1(i: I)
+      var x: number
+      x = i.s_var
+      x = i.o_var
+      x = i.s_var2
+      x = i.o_var2
+    enddef
+
+    def F2(o: C)
+      var x: number
+      x = o.s_var
+      x = o.o_var
+      x = o.s_var2
+      x = o.o_var2
+    enddef
+
+    g:instr1 = execute('disassemble F1')
+    g:instr2 = execute('disassemble F2')
+  END
+  v9.CheckScriptSuccess(lines)
+  assert_match('<SNR>\d*_F1\_s*' ..
+    'var x: number\_s*' ..
+    'x = i.s_var\_s*' ..
+    '0 LOAD arg\[-1\]\_s*' ..
+    '1 ITF_MEMBER 0 on I \[STATIC\]\_s*' ..
+    '2 STORE $0\_s*' ..
+    'x = i.o_var\_s*' ..
+    '3 LOAD arg\[-1\]\_s*' ..
+    '4 ITF_MEMBER 0 on I\_s*' ..
+    '5 STORE $0\_s*' ..
+    'x = i.s_var2\_s*' ..
+    '6 LOAD arg\[-1\]\_s*' ..
+    '7 ITF_MEMBER 1 on I \[STATIC\]\_s*' ..
+    '8 STORE $0\_s*' ..
+    'x = i.o_var2\_s*' ..
+    '9 LOAD arg\[-1\]\_s*' ..
+    '10 ITF_MEMBER 1 on I\_s*' ..
+    '11 STORE $0\_s*' ..
+    '12 RETURN void\_s*',
+    g:instr1)
+  assert_match('<SNR>\d*_F2\_s*' ..
+    'var x: number\_s*' ..
+    'x = o.s_var\_s*' ..
+    '0 LOAD arg\[-1\]\_s*' ..
+    '1 OBJ_MEMBER 0 \[STATIC\]\_s*' ..
+    '2 STORE $0\_s*' ..
+    'x = o.o_var\_s*' ..
+    '3 LOAD arg\[-1\]\_s*' ..
+    '4 OBJ_MEMBER 0\_s*' ..
+    '5 STORE $0\_s*' ..
+    'x = o.s_var2\_s*' ..
+    '6 LOAD arg\[-1\]\_s*' ..
+    '7 OBJ_MEMBER 1 \[STATIC\]\_s*' ..
+    ' 8 STORE $0\_s*' ..
+    'x = o.o_var2\_s*' ..
+    '9 LOAD arg\[-1\]\_s*' ..
+    '10 OBJ_MEMBER 1\_s*' ..
+    '11 STORE $0\_s*' ..
+    '12 RETURN void',
+    g:instr2)
+
+  unlet g:instr1
+  unlet g:instr2
+enddef
+
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1875,
+/**/
     1874,
 /**/
     1873,