diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-21 16:42:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-21 16:42:22 +0200 |
commit | ca17453e73fe69dc25a9d703804877a60763b685 (patch) | |
tree | 224ea9cada39389b9409a9ebb97c46990ed57b00 /src/testdir/test_vim9_builtin.vim | |
parent | 8a99e66b4f7616d9b0b9cefe742f82f9122087d5 (diff) |
patch 8.2.1879: Vim9: argument types of insert() not checked when compilingv8.2.1879
Problem: Vim9: argument types of insert() not checked when compiling.
Solution: Add argument type checks for insert().
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index fb94746c7e..e3d7bb628d 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -318,13 +318,20 @@ def Test_index() index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) enddef -def Test_insert_return_type() +def Test_insert() var l = insert([2, 1], 3) var res = 0 for n in l res += n endfor res->assert_equal(6) + + assert_equal([1, 2, 3], insert([2, 3], 1)) + assert_equal([1, 2, 3], insert([1, 2], 3, 2)) + assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a')) + assert_equal(0z1234, insert(0z34, 0x12)) + CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 1) + CheckDefFailure(['insert([2, 3], 1, "x")'], 'E1013: Argument 3: type mismatch, expected number but got string', 1) enddef def Test_keys_return_type() |