Mercurial > vim
comparison src/testdir/test_vim9_builtin.vim @ 22661:c6b17787a38f v8.2.1879
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Commit: https://github.com/vim/vim/commit/ca17453e73fe69dc25a9d703804877a60763b685
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Oct 21 16:42:22 2020 +0200
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Problem: Vim9: argument types of insert() not checked when compiling.
Solution: Add argument type checks for insert().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 21 Oct 2020 16:45:04 +0200 |
parents | eabe2c1444ea |
children | 9fa3f92248f6 |
comparison
equal
deleted
inserted
replaced
22660:479ed437fbaf | 22661:c6b17787a38f |
---|---|
316 | 316 |
317 def Test_index() | 317 def Test_index() |
318 index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) | 318 index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) |
319 enddef | 319 enddef |
320 | 320 |
321 def Test_insert_return_type() | 321 def Test_insert() |
322 var l = insert([2, 1], 3) | 322 var l = insert([2, 1], 3) |
323 var res = 0 | 323 var res = 0 |
324 for n in l | 324 for n in l |
325 res += n | 325 res += n |
326 endfor | 326 endfor |
327 res->assert_equal(6) | 327 res->assert_equal(6) |
328 | |
329 assert_equal([1, 2, 3], insert([2, 3], 1)) | |
330 assert_equal([1, 2, 3], insert([1, 2], 3, 2)) | |
331 assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a')) | |
332 assert_equal(0z1234, insert(0z34, 0x12)) | |
333 CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 1) | |
334 CheckDefFailure(['insert([2, 3], 1, "x")'], 'E1013: Argument 3: type mismatch, expected number but got string', 1) | |
328 enddef | 335 enddef |
329 | 336 |
330 def Test_keys_return_type() | 337 def Test_keys_return_type() |
331 const var: list<string> = #{a: 1, b: 2}->keys() | 338 const var: list<string> = #{a: 1, b: 2}->keys() |
332 var->assert_equal(['a', 'b']) | 339 var->assert_equal(['a', 'b']) |