Patch 8.2.4809
Problem:    Various things not properly tested.
Solution:   Add various test cases. (Yegappan Lakshmanan, closes #10259)
Files:      src/testdir/test_blob.vim, src/testdir/test_debugger.vim,
            src/testdir/test_listdict.vim, src/testdir/test_vim9_builtin.vim,
            src/testdir/test_vim9_import.vim, src/testdir/test_vim9_script.vim


*** ../vim-8.2.4808/src/testdir/test_blob.vim   2022-04-03 11:22:33.528172299 
+0100
--- src/testdir/test_blob.vim   2022-04-23 10:46:04.752132997 +0100
***************
*** 118,123 ****
--- 118,125 ----
        LET b[1 : 1] ..= 0z55
    END
    call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:'])
+ 
+   call assert_fails('let b = readblob("a1b2c3")', 'E484:')
  endfunc
  
  func Test_blob_get_range()
***************
*** 210,215 ****
--- 212,219 ----
        call assert_true(b1 == b2)
        call assert_false(b1 is b2)
        call assert_true(b1 isnot b2)
+       call assert_true(0z != 0z10)
+       call assert_true(0z10 != 0z)
    END
    call v9.CheckLegacyAndVim9Success(lines)
  
***************
*** 266,272 ****
        VAR b = 0z00
        LET b[1] = 0x11
        LET b[2] = 0x22
!       call assert_equal(0z001122, b)
    END
    call v9.CheckLegacyAndVim9Success(lines)
  
--- 270,277 ----
        VAR b = 0z00
        LET b[1] = 0x11
        LET b[2] = 0x22
!       LET b[0] = 0x33
!       call assert_equal(0z331122, b)
    END
    call v9.CheckLegacyAndVim9Success(lines)
  
***************
*** 281,286 ****
--- 286,303 ----
        LET b[-2] = 0x33
    END
    call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
+ 
+   let lines =<< trim END
+       VAR b = 0z00010203
+       LET b[0 : -1] = 0z33
+   END
+   call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
+ 
+   let lines =<< trim END
+       VAR b = 0z00010203
+       LET b[3 : 4] = 0z3344
+   END
+   call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
  endfunc
  
  func Test_blob_for_loop()
***************
*** 426,431 ****
--- 443,454 ----
    END
    call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
  
+   let lines =<< trim END
+       VAR b = 0zDEADBEEF
+       call remove(b, -10)
+   END
+   call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
+ 
    let lines =<< trim END
        VAR b = 0zDEADBEEF
        call remove(b, 3, 2)
*** ../vim-8.2.4808/src/testdir/test_debugger.vim       2022-03-10 
20:47:38.557606237 +0000
--- src/testdir/test_debugger.vim       2022-04-23 10:46:04.756132987 +0100
***************
*** 362,368 ****
    call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
  endfunc
  
! def Test_Debugger_breakadd_expr()
    var lines =<< trim END
        vim9script
        func g:EarlyFunc()
--- 362,400 ----
    call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
  endfunc
  
! " Test for expression breakpoint set using ":breakadd expr <expr>"
! func Test_Debugger_breakadd_expr()
!   let lines =<< trim END
!     let g:Xtest_var += 1
!   END
!   call writefile(lines, 'Xtest.vim')
! 
!   " Start Vim in a terminal
!   let buf = RunVimInTerminal('Xtest.vim', {})
!   call RunDbgCmd(buf, ':let g:Xtest_var = 10')
!   call RunDbgCmd(buf, ':breakadd expr g:Xtest_var')
!   call RunDbgCmd(buf, ':source %')
!   let expected =<< eval trim END
!     Oldval = "10"
!     Newval = "11"
!     `=fnamemodify('Xtest.vim', ':p')`
!     line 1: let g:Xtest_var += 1
!   END
!   call RunDbgCmd(buf, ':source %', expected)
!   call RunDbgCmd(buf, 'cont')
!   let expected =<< eval trim END
!     Oldval = "11"
!     Newval = "12"
!     `=fnamemodify('Xtest.vim', ':p')`
!     line 1: let g:Xtest_var += 1
!   END
!   call RunDbgCmd(buf, ':source %', expected)
! 
!   call StopVimInTerminal(buf)
!   call delete('Xtest.vim')
! endfunc
! 
! def Test_Debugger_breakadd_vim9_expr()
    var lines =<< trim END
        vim9script
        func g:EarlyFunc()
*** ../vim-8.2.4808/src/testdir/test_listdict.vim       2022-03-20 
17:46:01.797053490 +0000
--- src/testdir/test_listdict.vim       2022-04-23 10:46:04.756132987 +0100
***************
*** 1017,1022 ****
--- 1017,1023 ----
  
    call assert_fails("call reduce([], { acc, val -> acc + val })", 'E998: 
Reduce of an empty List with no initial value')
    call assert_fails("call reduce(0z, { acc, val -> acc + val })", 'E998: 
Reduce of an empty Blob with no initial value')
+   call assert_fails("call reduce(test_null_blob(), { acc, val -> acc + val 
})", 'E998: Reduce of an empty Blob with no initial value')
    call assert_fails("call reduce('', { acc, val -> acc + val })", 'E998: 
Reduce of an empty String with no initial value')
    call assert_fails("call reduce(test_null_string(), { acc, val -> acc + val 
})", 'E998: Reduce of an empty String with no initial value')
  
***************
*** 1034,1041 ****
    call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 
'E1253:')
    call assert_fails("call reduce('', { acc, val -> acc + val }, 
function('tr'))", 'E1253:')
    call assert_fails("call reduce('abc', { a, v -> a10}, '')", 'E121:')
!   call assert_fails("call reduce(0z01, { a, v -> a10}, 1)", 'E121:')
!   call assert_fails("call reduce([1], { a, v -> a10}, '')", 'E121:')
  
    let g:lut = [1, 2, 3, 4]
    func EvilRemove()
--- 1035,1042 ----
    call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 
'E1253:')
    call assert_fails("call reduce('', { acc, val -> acc + val }, 
function('tr'))", 'E1253:')
    call assert_fails("call reduce('abc', { a, v -> a10}, '')", 'E121:')
!   call assert_fails("call reduce(0z0102, { a, v -> a10}, 1)", 'E121:')
!   call assert_fails("call reduce([1, 2], { a, v -> a10}, '')", 'E121:')
  
    let g:lut = [1, 2, 3, 4]
    func EvilRemove()
*** ../vim-8.2.4808/src/testdir/test_vim9_builtin.vim   2022-04-18 
19:16:50.929953487 +0100
--- src/testdir/test_vim9_builtin.vim   2022-04-23 10:46:04.756132987 +0100
***************
*** 1273,1328 ****
--- 1273,1351 ----
  
    # acos()
    v9.CheckDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('1.570796', string(acos(0.0)))
    # asin()
    v9.CheckDefAndScriptFailure(['asin("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(asin(0.0)))
    # atan()
    v9.CheckDefAndScriptFailure(['atan("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(atan(0.0)))
    # atan2()
    v9.CheckDefAndScriptFailure(['atan2("a", 1.1)'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('-2.356194', string(atan2(-1, -1)))
    v9.CheckDefAndScriptFailure(['atan2(1.2, "a")'], ['E1013: Argument 2: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 2'])
    v9.CheckDefAndScriptFailure(['atan2(1.2)'], ['E119:', 'E119:'])
    # ceil()
    v9.CheckDefAndScriptFailure(['ceil("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('2.0', string(ceil(2.0)))
    # cos()
    v9.CheckDefAndScriptFailure(['cos("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('1.0', string(cos(0.0)))
    # cosh()
    v9.CheckDefAndScriptFailure(['cosh("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('1.0', string(cosh(0.0)))
    # exp()
    v9.CheckDefAndScriptFailure(['exp("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('1.0', string(exp(0.0)))
    # float2nr()
    v9.CheckDefAndScriptFailure(['float2nr("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal(1, float2nr(1.234))
    # floor()
    v9.CheckDefAndScriptFailure(['floor("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('2.0', string(floor(2.0)))
    # fmod()
    v9.CheckDefAndScriptFailure(['fmod(1.1, "a")'], ['E1013: Argument 2: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 2'])
    v9.CheckDefAndScriptFailure(['fmod("a", 1.1)'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
    v9.CheckDefAndScriptFailure(['fmod(1.1)'], ['E119:', 'E119:'])
+   assert_equal('0.13', string(fmod(12.33, 1.22)))
    # isinf()
    v9.CheckDefAndScriptFailure(['isinf("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal(1, isinf(1.0 / 0.0))
    # isnan()
    v9.CheckDefAndScriptFailure(['isnan("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_true(isnan(0.0 / 0.0))
    # log()
    v9.CheckDefAndScriptFailure(['log("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(log(1.0)))
    # log10()
    v9.CheckDefAndScriptFailure(['log10("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(log10(1.0)))
    # pow()
    v9.CheckDefAndScriptFailure(['pow("a", 1.1)'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
    v9.CheckDefAndScriptFailure(['pow(1.1, "a")'], ['E1013: Argument 2: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 2'])
    v9.CheckDefAndScriptFailure(['pow(1.1)'], ['E119:', 'E119:'])
+   assert_equal('1.0', string(pow(0.0, 0.0)))
    # round()
    v9.CheckDefAndScriptFailure(['round("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('2.0', string(round(2.1)))
    # sin()
    v9.CheckDefAndScriptFailure(['sin("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(sin(0.0)))
    # sinh()
    v9.CheckDefAndScriptFailure(['sinh("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(sinh(0.0)))
    # sqrt()
    v9.CheckDefAndScriptFailure(['sqrt("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(sqrt(0.0)))
    # tan()
    v9.CheckDefAndScriptFailure(['tan("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(tan(0.0)))
    # tanh()
    v9.CheckDefAndScriptFailure(['tanh("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('0.0', string(tanh(0.0)))
    # trunc()
    v9.CheckDefAndScriptFailure(['trunc("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1219: Float or Number required for 
argument 1'])
+   assert_equal('2.0', string(trunc(2.1)))
  enddef
  
  def Test_fnameescape()
*** ../vim-8.2.4808/src/testdir/test_vim9_import.vim    2022-04-15 
22:57:05.523488055 +0100
--- src/testdir/test_vim9_import.vim    2022-04-23 10:46:04.756132987 +0100
***************
*** 506,513 ****
    END
    v9.CheckScriptFailure(lines, 'E1047:')
  
-   delete('Xfoo.vim')
- 
    lines =<< trim END
        vim9script
        def TheFunc()
--- 506,511 ----
***************
*** 576,582 ****
--- 574,599 ----
    END
    v9.CheckScriptSuccess(lines)
  
+   new
+   setline(1, ['vim9script', 'import "" as abc'])
+   assert_fails('source', 'E1071: Invalid string for :import: "" as abc')
+   setline(2, 'import [] as abc')
+   assert_fails('source', 'E1071: Invalid string for :import: [] as abc')
+   setline(2, 'import test_null_string() as abc')
+   assert_fails('source', 'E1071: Invalid string for :import: 
test_null_string() as abc')
+   bw!
+   call writefile(['vim9script', "import './Xfoo.vim' ask expo"], 'Xbar.vim')
+   assert_fails('source Xbar.vim', 'E488: Trailing characters: ask expo')
+   writefile([], 'Xtemp')
+   call writefile(['vim9script', "import './Xtemp'"], 'Xbar.vim')
+   assert_fails('source Xbar.vim', 'E1257: Imported script must use "as" or 
end in .vim: Xtemp')
+   delete('Xtemp')
+   call writefile(['vim9script', "import './Xfoo.vim' as abc | foobar"], 
'Xbar.vim')
+   assert_fails('source Xbar.vim', 'E492: Not an editor command:  foobar')
+   call delete('Xbar.vim')
+ 
    delete('Ximport', 'rf')
+   delete('Xfoo.vim')
  enddef
  
  func g:Trigger()
***************
*** 1404,1409 ****
--- 1421,1427 ----
    v9.CheckScriptFailure(['export var some = 123'], 'E1042:')
    v9.CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
    v9.CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:')
+   v9.CheckScriptFailure(['vim9script', 'export function /a1b2c3'], 'E1044:')
  
    assert_fails('export something', 'E1043:')
  enddef
***************
*** 2646,2651 ****
--- 2664,2675 ----
        var n = 0
    END
    v9.CheckScriptFailure(lines, 'E983: Duplicate argument: noclear')
+ 
+   lines =<< trim END
+       vim9script noclears
+       var n = 0
+   END
+   v9.CheckScriptFailure(lines, 'E475: Invalid argument: noclears')
  enddef
  
  def Test_import_autoload_fails()
*** ../vim-8.2.4808/src/testdir/test_vim9_script.vim    2022-04-03 
21:11:31.031579240 +0100
--- src/testdir/test_vim9_script.vim    2022-04-23 10:46:04.756132987 +0100
***************
*** 3780,3785 ****
--- 3780,3795 ----
    v9.CheckDefAndScriptFailure(lines, ['E476:', 'E492:'])
  
    lines =<< trim END
+       :k a
+   END
+   v9.CheckDefAndScriptFailure(lines, 'E1100:')
+ 
+   lines =<< trim END
+       :1k a
+   END
+   v9.CheckDefAndScriptFailure(lines, 'E481:')
+ 
+   lines =<< trim END
      t
    END
    v9.CheckDefAndScriptFailure(lines, 'E1100:')
*** ../vim-8.2.4808/src/version.c       2022-04-23 10:41:31.092696680 +0100
--- src/version.c       2022-04-23 10:49:54.467659771 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4809,
  /**/

-- 
Seen it all, done it all, can't remember most of it.

 /// 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/20220423095223.271BC1C43E2%40moolenaar.net.

Raspunde prin e-mail lui