diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-16 20:08:35 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-16 20:08:35 +0100 |
commit | 193f6201b4d5c76f8dc1faa1dcf369575d93fe3a (patch) | |
tree | 6e4225c94d9d04cb33244ac4d87c4c6f9f53b787 /src/testdir/test_vim9_builtin.vim | |
parent | 714cbe5b212abbecb578b90424d89f47142e8f25 (diff) |
patch 8.2.1996: Vim9: invalid error for argument of extend()v8.2.1996
Problem: Vim9: invalid error for argument of extend().
Solution: Check if the type could match. (closes #7299)
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index bbb7e85d0f..cf122673c3 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -195,10 +195,16 @@ def Test_extend_arg_types() assert_equal([1, 2, 3], extend([1, 2], [3])) assert_equal([3, 1, 2], extend([1, 2], [3], 0)) assert_equal([1, 3, 2], extend([1, 2], [3], 1)) + assert_equal([1, 3, 2], extend([1, 2], [3], s:number_one)) assert_equal(#{a: 1, b: 2, c: 3}, extend(#{a: 1, b: 2}, #{c: 3})) assert_equal(#{a: 1, b: 4}, extend(#{a: 1, b: 2}, #{b: 4})) assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, 'keep')) + assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, s:string_keep)) + + var res: list<dict<any>> + extend(res, map([1, 2], {_, v -> {}})) + assert_equal([{}, {}], res) CheckDefFailure(['extend([1, 2], 3)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number') CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>') @@ -338,6 +344,10 @@ def Test_index() index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) enddef +let s:number_one = 1 +let s:number_two = 2 +let s:string_keep = 'keep' + def Test_insert() var l = insert([2, 1], 3) var res = 0 @@ -347,9 +357,12 @@ def Test_insert() res->assert_equal(6) assert_equal([1, 2, 3], insert([2, 3], 1)) + assert_equal([1, 2, 3], insert([2, 3], s:number_one)) assert_equal([1, 2, 3], insert([1, 2], 3, 2)) + assert_equal([1, 2, 3], insert([1, 2], 3, s:number_two)) 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 |