diff src/testdir/test_vim9_disassemble.vim @ 20909:0d7465881b06 v8.2.1006

patch 8.2.1006: Vim9: require unnecessary return statement Commit: https://github.com/vim/vim/commit/efd885559405e1561d577e1b0e6fa827705d285e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 18 20:50:10 2020 +0200 patch 8.2.1006: Vim9: require unnecessary return statement Problem: Vim9: require unnecessary return statement. Solution: Improve the use of the had_return flag. (closes https://github.com/vim/vim/issues/6270)
author Bram Moolenaar <Bram@vim.org>
date Thu, 18 Jun 2020 21:00:04 +0200
parents 489cb75c76b6
children a127db33a075
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -533,6 +533,30 @@ def Test_disassemble_const_expr()
   assert_notmatch('JUMP', instr)
 enddef
 
+def ReturnInIf(): string
+  if g:cond
+    return "yes"
+  else
+    return "no"
+  endif
+enddef
+
+def Test_disassemble_return_in_if()
+  let instr = execute('disassemble ReturnInIf')
+  assert_match('ReturnInIf\_s*' ..
+        'if g:cond\_s*' ..
+        '0 LOADG g:cond\_s*' ..
+        '1 JUMP_IF_FALSE -> 4\_s*' ..
+        'return "yes"\_s*' ..
+        '2 PUSHS "yes"\_s*' ..
+        '3 RETURN\_s*' ..
+        'else\_s*' ..
+        ' return "no"\_s*' ..
+        '4 PUSHS "no"\_s*' ..
+        '5 RETURN$',
+        instr)
+enddef
+
 def WithFunc()
   let Funky1: func
   let Funky2: func = function("len")