]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1569: tests: Vim9 tests can be improved v9.1.1569
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 20 Jul 2025 07:55:07 +0000 (09:55 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Jul 2025 07:55:07 +0000 (09:55 +0200)
Problem:  tests: Vim9 tests can be improved
Solution: In Test_has_func_shortcircuit(), move the test functions to a
          separate script (Yegappan Lakshmanan)

closes: #17796

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_script.vim
src/version.c

index 268ceb482487561dbdde68a48265873992c3f934..0008f1e51d095f5fd2b6fa0d37b131eeda8ac71d 100644 (file)
@@ -5267,59 +5267,83 @@ enddef
 
 " Test for using more than one has() check in a compound if condition.
 def Test_has_func_shortcircuit()
-  def Has_And1_Cond(): string
-    # true && false
-    if has('jumplist') && has('foobar')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('missing', Has_And1_Cond())
+  var lines =<< trim END
+    vim9script
+    def Has_And1_Cond(): string
+      # true && false
+      if has('jumplist') && has('foobar')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('missing', Has_And1_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 
-  def Has_And2_Cond(): string
-    # false && true
-    if has('foobar') && has('jumplist')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('missing', Has_And2_Cond())
+  lines =<< trim END
+    vim9script
+    def Has_And2_Cond(): string
+      # false && true
+      if has('foobar') && has('jumplist')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('missing', Has_And2_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 
-  def Has_And3_Cond(): string
-    # false && false
-    if has('foobar') && has('foobaz')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('missing', Has_And3_Cond())
+  lines =<< trim END
+    vim9script
+    def Has_And3_Cond(): string
+      # false && false
+      if has('foobar') && has('foobaz')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('missing', Has_And3_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 
-  def Has_Or1_Cond(): string
-    # true || false
-    if has('jumplist') || has('foobar')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('present', Has_Or1_Cond())
+  lines =<< trim END
+    vim9script
+    def Has_Or1_Cond(): string
+      # true || false
+      if has('jumplist') || has('foobar')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('present', Has_Or1_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 
-  def Has_Or2_Cond(): string
-    # false || true
-    if has('foobar') || has('jumplist')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('present', Has_Or2_Cond())
+  lines =<< trim END
+    vim9script
+    def Has_Or2_Cond(): string
+      # false || true
+      if has('foobar') || has('jumplist')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('present', Has_Or2_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 
-  def Has_Or3_Cond(): string
-    # false || false
-    if has('foobar') || has('foobaz')
-      return 'present'
-    endif
-    return 'missing'
-  enddef
-  assert_equal('missing', Has_Or3_Cond())
+  lines =<< trim END
+    vim9script
+    def Has_Or3_Cond(): string
+      # false || false
+      if has('foobar') || has('foobaz')
+        return 'present'
+      endif
+      return 'missing'
+    enddef
+    assert_equal('missing', Has_Or3_Cond())
+  END
+  v9.CheckSourceSuccess(lines)
 enddef
 
 " Test for using more than one len() function in a compound if condition.
index 62f61e4a7824b52c32372edf3172af9dd675a96b..7297bc8cc2304afe714d70eab26bc9bdc55dd61e 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1569,
 /**/
     1568,
 /**/