comparison src/testdir/test_vim9_builtin.vim @ 25216:9ead67e3c696 v8.2.3144

patch 8.2.3144: Vim9: no error when using an invalid value for a line number Commit: https://github.com/vim/vim/commit/0f1227f7d5a3e368f61d396c1640088c079fef91 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 11 16:01:58 2021 +0200 patch 8.2.3144: Vim9: no error when using an invalid value for a line number Problem: Vim9: no error when using an invalid value for a line number. Solution: Give an error if the string value is not recognized. (closes #8536)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Jul 2021 16:15:03 +0200
parents 79eb112b492d
children 10a5eb15a3bf
comparison
equal deleted inserted replaced
25215:a7588e54bd5d 25216:9ead67e3c696
472 assert_equal(4, getcurpos()[1]) 472 assert_equal(4, getcurpos()[1])
473 473
474 var lines =<< trim END 474 var lines =<< trim END
475 cursor('2', 1) 475 cursor('2', 1)
476 END 476 END
477 CheckDefExecAndScriptFailure(lines, 'E475:') 477 CheckDefExecAndScriptFailure(lines, 'E1209:')
478 enddef 478 enddef
479 479
480 def Test_debugbreak() 480 def Test_debugbreak()
481 CheckMSWindows 481 CheckMSWindows
482 CheckDefFailure(['debugbreak("x")'], 'E1013: Argument 1: type mismatch, expected number but got string') 482 CheckDefFailure(['debugbreak("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
1034 CheckDefFailure(['getjumplist("x")'], 'E1013: Argument 1: type mismatch, expected number but got string') 1034 CheckDefFailure(['getjumplist("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
1035 CheckDefFailure(['getjumplist("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string') 1035 CheckDefFailure(['getjumplist("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
1036 CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string') 1036 CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
1037 enddef 1037 enddef
1038 1038
1039 def Test_getline()
1040 var lines =<< trim END
1041 new
1042 setline(1, ['hello', 'there', 'again'])
1043 assert_equal('hello', getline(1))
1044 assert_equal('hello', getline('.'))
1045
1046 normal 2Gvjv
1047 assert_equal('there', getline("'<"))
1048 assert_equal('again', getline("'>"))
1049 END
1050 CheckDefAndScriptSuccess(lines)
1051
1052 lines =<< trim END
1053 echo getline('1')
1054 END
1055 CheckDefExecAndScriptFailure(lines, 'E1209:')
1056 enddef
1057
1039 def Test_getmarklist() 1058 def Test_getmarklist()
1040 CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>') 1059 CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
1041 assert_equal([], getmarklist(10000)) 1060 assert_equal([], getmarklist(10000))
1042 assert_fails('getmarklist("a%b@#")', 'E94:') 1061 assert_fails('getmarklist("a%b@#")', 'E94:')
1043 enddef 1062 enddef
1047 enddef 1066 enddef
1048 1067
1049 def Test_getpos() 1068 def Test_getpos()
1050 CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected string but got number') 1069 CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
1051 assert_equal([0, 1, 1, 0], getpos('.')) 1070 assert_equal([0, 1, 1, 0], getpos('.'))
1052 assert_equal([0, 0, 0, 0], getpos('a')) 1071 CheckDefExecFailure(['getpos("a")'], 'E1209:')
1053 enddef 1072 enddef
1054 1073
1055 def Test_getqflist() 1074 def Test_getqflist()
1056 CheckDefFailure(['getqflist([])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<unknown>') 1075 CheckDefFailure(['getqflist([])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<unknown>')
1057 call assert_equal({}, getqflist({})) 1076 call assert_equal({}, getqflist({}))