Mercurial > vim
comparison src/testdir/test_user_func.vim @ 24685:04205b7d67d5 v8.2.2881
patch 8.2.2881: various pieces of code not covered by tests
Commit: https://github.com/vim/vim/commit/611728f80604dd56960e8c197e5749d203c8feb1
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon May 24 15:15:47 2021 +0200
patch 8.2.2881: various pieces of code not covered by tests
Problem: Various pieces of code not covered by tests.
Solution: Add a few more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8245)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 May 2021 15:30:03 +0200 |
parents | da8b8a320bb3 |
children | 13efbfc53054 |
comparison
equal
deleted
inserted
replaced
24684:1706f44ede8e | 24685:04205b7d67d5 |
---|---|
403 endfunc | 403 endfunc |
404 END | 404 END |
405 let l = join(lines, "\n") . "\n" | 405 let l = join(lines, "\n") . "\n" |
406 exe l | 406 exe l |
407 call assert_fails('exe l', 'E717:') | 407 call assert_fails('exe l', 'E717:') |
408 call assert_fails('call feedkeys(":func d.F1()\<CR>", "xt")', 'E717:') | |
408 | 409 |
409 " Define an autoload function with an incorrect file name | 410 " Define an autoload function with an incorrect file name |
410 call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') | 411 call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') |
411 call assert_fails('source Xscript', 'E746:') | 412 call assert_fails('source Xscript', 'E746:') |
412 call delete('Xscript') | 413 call delete('Xscript') |
418 " Test for deleting a function | 419 " Test for deleting a function |
419 func Test_del_func() | 420 func Test_del_func() |
420 call assert_fails('delfunction Xabc', 'E130:') | 421 call assert_fails('delfunction Xabc', 'E130:') |
421 let d = {'a' : 10} | 422 let d = {'a' : 10} |
422 call assert_fails('delfunc d.a', 'E718:') | 423 call assert_fails('delfunc d.a', 'E718:') |
424 func d.fn() | |
425 return 1 | |
426 endfunc | |
427 delfunc d.fn | |
428 call assert_equal({'a' : 10}, d) | |
423 endfunc | 429 endfunc |
424 | 430 |
425 " Test for calling return outside of a function | 431 " Test for calling return outside of a function |
426 func Test_return_outside_func() | 432 func Test_return_outside_func() |
427 call writefile(['return 10'], 'Xscript') | 433 call writefile(['return 10'], 'Xscript') |
449 let mydict = {'a': 'b'} | 455 let mydict = {'a': 'b'} |
450 function mydict.somefunc() dict | 456 function mydict.somefunc() dict |
451 return len(self) | 457 return len(self) |
452 endfunc | 458 endfunc |
453 | 459 |
454 call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict)) | 460 call assert_equal("{'a': 'b', 'somefunc': function('3')}", string(mydict)) |
455 call assert_equal(2, mydict.somefunc()) | 461 call assert_equal(2, mydict.somefunc()) |
456 call assert_match("^\n function \\d\\\+() dict" | 462 call assert_match("^\n function \\d\\\+() dict" |
457 \ .. "\n1 return len(self)" | 463 \ .. "\n1 return len(self)" |
458 \ .. "\n endfunction$", execute('func mydict.somefunc')) | 464 \ .. "\n endfunction$", execute('func mydict.somefunc')) |
465 call assert_fails('call mydict.nonexist()', 'E716:') | |
459 endfunc | 466 endfunc |
460 | 467 |
461 func Test_func_range() | 468 func Test_func_range() |
462 new | 469 new |
463 call setline(1, range(1, 8)) | 470 call setline(1, range(1, 8)) |