diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-07-21 19:09:09 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-21 19:09:09 +0200 |
commit | cd9172077bc8c0aafddf2e5367cc0ae2c00c8ff7 (patch) | |
tree | d460cabb1f58286f763089e7a9552be6c21059f3 /src/testdir | |
parent | 189663bdac1156237c49925f77bd197c1bdea12c (diff) |
patch 8.2.3194: Vim9: argument types are not checked at compile timev8.2.3194
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks, simplify some. (Yegappan
Lakshmanan, closes #8598)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 869915074d..fb9c868ecc 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -652,6 +652,8 @@ def Test_cursor() assert_equal(2, getcurpos()[1]) cursor('$', 1) assert_equal(4, getcurpos()[1]) + cursor([2, 1]) + assert_equal(2, getcurpos()[1]) var lines =<< trim END cursor('2', 1) @@ -1105,6 +1107,7 @@ def Test_getbufinfo() getbufinfo({bufloaded: true, buflisted: true, bufmodified: false}) ->len()->assert_equal(3) bwipe Xtestfile1 Xtestfile2 + CheckDefAndScriptFailure2(['getbufinfo(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1') enddef def Test_getbufline() @@ -1246,6 +1249,8 @@ def Test_getline() echo getline('1') END CheckDefExecAndScriptFailure(lines, 'E1209:') + CheckDefAndScriptFailure2(['getline(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['getline(1, true)'], 'E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2') enddef def Test_getloclist() @@ -3066,6 +3071,12 @@ def Test_term_getjob() CheckDefAndScriptFailure2(['term_getjob(0z10)'], 'E1013: Argument 1: type mismatch, expected string but got blob', 'E974: Using a Blob as a Number') enddef +def Test_term_getline() + CheckRunVimInTerminal + CheckDefAndScriptFailure2(['term_getline(1.1, 1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['term_getline(1, 1.1)'], 'E1013: Argument 2: type mismatch, expected string but got float', 'E1174: String required for argument 2') +enddef + def Test_term_getscrolled() CheckRunVimInTerminal CheckDefAndScriptFailure2(['term_getscrolled(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E805: Using a Float as a Number') @@ -3098,6 +3109,12 @@ def Test_term_gettty() CheckDefAndScriptFailure2(['term_gettty(1, 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2') enddef +def Test_term_scrape() + CheckRunVimInTerminal + CheckDefAndScriptFailure2(['term_scrape(1.1, 1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['term_scrape(1, 1.1)'], 'E1013: Argument 2: type mismatch, expected string but got float', 'E1174: String required for argument 2') +enddef + def Test_term_sendkeys() CheckRunVimInTerminal CheckDefAndScriptFailure2(['term_sendkeys([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1') @@ -3127,6 +3144,14 @@ def Test_term_setrestore() CheckDefAndScriptFailure2(['term_setrestore([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1') CheckDefAndScriptFailure2(['term_setrestore(1, [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2') enddef + +def Test_term_setsize() + CheckRunVimInTerminal + CheckDefAndScriptFailure2(['term_setsize(1.1, 2, 3)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['term_setsize(1, "2", 3)'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + CheckDefAndScriptFailure2(['term_setsize(1, 2, "3")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3') +enddef + def Test_term_start() if !has('terminal') CheckFeature terminal @@ -3137,6 +3162,9 @@ def Test_term_start() winnr()->assert_equal(winnr) bwipe! endif + CheckDefAndScriptFailure2(['term_start({})'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['term_start([], [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 2') + CheckDefAndScriptFailure2(['term_start("", "")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2') enddef def Test_term_wait() |