Patch 9.0.0543
Problem:    Insufficient testing for assert and test functions.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #11190)
Files:      src/testdir/test_assert.vim, src/testdir/test_options.vim,
            src/testdir/test_vimscript.vim


*** ../vim-9.0.0542/src/testdir/test_assert.vim 2022-09-17 21:07:52.103993150 
+0100
--- src/testdir/test_assert.vim 2022-09-22 13:41:57.599406980 +0100
***************
*** 269,274 ****
--- 269,288 ----
    call assert_match("E856: \"assert_fails()\" second argument", exp)
  
    try
+     call assert_equal(1, assert_fails('xxx', test_null_list()))
+   catch
+     let exp = v:exception
+   endtry
+   call assert_match("E856: \"assert_fails()\" second argument", exp)
+ 
+   try
+     call assert_equal(1, assert_fails('xxx', []))
+   catch
+     let exp = v:exception
+   endtry
+   call assert_match("E856: \"assert_fails()\" second argument", exp)
+ 
+   try
      call assert_equal(1, assert_fails('xxx', #{one: 1}))
    catch
      let exp = v:exception
***************
*** 307,312 ****
--- 321,335 ----
    call assert_equal(1, assert_fails('c0', ['', '\(.\)\1']))
    call assert_match("Expected '\\\\\\\\(.\\\\\\\\)\\\\\\\\1' but got 'E939: 
Positive count required: c0': c0", v:errors[0])
    call remove(v:errors, 0)
+ 
+   " Test for matching the line number and the script name in an error message
+   call writefile(['', 'call Xnonexisting()'], 'Xassertfails.vim', 'D')
+   call assert_fails('source Xassertfails.vim', 'E117:', '', 10)
+   call assert_match("Expected 10 but got 2", v:errors[0])
+   call remove(v:errors, 0)
+   call assert_fails('source Xassertfails.vim', 'E117:', '', 2, 'Xabc')
+   call assert_match("Expected 'Xabc' but got .*Xassertfails.vim", v:errors[0])
+   call remove(v:errors, 0)
  endfunc
  
  func Test_assert_fails_in_try_block()
***************
*** 331,336 ****
--- 354,365 ----
    bwipe
  endfunc
  
+ func Test_assert_nobeep()
+   call assert_equal(1, assert_nobeep('normal! cr'))
+   call assert_match("command did beep: normal! cr", v:errors[0])
+   call remove(v:errors, 0)
+ endfunc
+ 
  func Test_assert_inrange()
    call assert_equal(0, assert_inrange(7, 7, 7))
    call assert_equal(0, assert_inrange(5, 7, 5))
***************
*** 365,370 ****
--- 394,409 ----
    call assert_equal(1, assert_inrange(5, 7, 8.0))
    call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
    call remove(v:errors, 0)
+ 
+   " Use a custom message
+   call assert_equal(1, assert_inrange(5, 7, 8.0, "Higher"))
+   call assert_match("Higher", v:errors[0])
+   call remove(v:errors, 0)
+ 
+   " Invalid arguments
+   call assert_fails("call assert_inrange([], 2, 3)", 'E1219:')
+   call assert_fails("call assert_inrange(1, [], 3)", 'E1219:')
+   call assert_fails("call assert_inrange(1, 2, [])", 'E1219:')
  endfunc
  
  func Test_assert_with_msg()
***************
*** 407,412 ****
--- 446,464 ----
    sleep 300m
  endfunc
  
+ " Test for the test_alloc_fail() function
+ func Test_test_alloc_fail()
+   call assert_fails('call test_alloc_fail([], 1, 1)', 'E474:')
+   call assert_fails('call test_alloc_fail(10, [], 1)', 'E474:')
+   call assert_fails('call test_alloc_fail(10, 1, [])', 'E474:')
+   call assert_fails('call test_alloc_fail(999999, 1, 1)', 'E474:')
+ endfunc
+ 
+ " Test for the test_option_not_set() function
+ func Test_test_option_not_set()
+   call assert_fails('call test_option_not_set("Xinvalidopt")', 'E475:')
+ endfunc
+ 
  " Must be last.
  func Test_zz_quit_detected()
    " Verify that if a test function ends Vim the test script detects this.
*** ../vim-9.0.0542/src/testdir/test_options.vim        2022-09-02 
21:55:45.503049444 +0100
--- src/testdir/test_options.vim        2022-09-22 13:41:57.599406980 +0100
***************
*** 815,820 ****
--- 815,821 ----
    call assert_match('file2', execute('bn', ''))
    bwipe
    bwipe
+   call assert_fails('call test_getvalue("abc")', 'E475:')
  endfunc
  
  func Test_local_scrolloff()
*** ../vim-9.0.0542/src/testdir/test_vimscript.vim      2022-09-17 
21:07:52.111993132 +0100
--- src/testdir/test_vimscript.vim      2022-09-22 13:41:57.599406980 +0100
***************
*** 7216,7221 ****
--- 7216,7229 ----
      call d.Func()
      unlet d
      delfunc DictFunc
+ 
+     call assert_equal(-1, test_refcount(test_null_job()))
+     call assert_equal(-1, test_refcount(test_null_channel()))
+     call assert_equal(-1, test_refcount(test_null_function()))
+     call assert_equal(-1, test_refcount(test_null_partial()))
+     call assert_equal(-1, test_refcount(test_null_blob()))
+     call assert_equal(-1, test_refcount(test_null_list()))
+     call assert_equal(-1, test_refcount(test_null_dict()))
  endfunc
  
  " Test for missing :endif, :endfor, :endwhile and :endtry           {{{1
*** ../vim-9.0.0542/src/version.c       2022-09-22 13:17:13.626518649 +0100
--- src/version.c       2022-09-22 13:43:11.447408297 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     543,
  /**/

-- 
Why is it called "Windows"?  "Gates" would be more appropriate...

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220922124432.807AB1C071C%40moolenaar.net.

Raspunde prin e-mail lui