Mercurial > vim
comparison src/testdir/test_python2.vim @ 21200:37edecbfb834 v8.2.1151
patch 8.2.1151: insufficient test coverage for Python
Commit: https://github.com/vim/vim/commit/0ab55d62012c1fb38c4b540a4233421820a59389
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 7 20:50:39 2020 +0200
patch 8.2.1151: insufficient test coverage for Python
Problem: Insufficient test coverage for Python.
Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6415)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Jul 2020 21:00:04 +0200 |
parents | 8531ddd7dd63 |
children | 6a4806e326dd |
comparison
equal
deleted
inserted
replaced
21199:a9ce04b178c4 | 21200:37edecbfb834 |
---|---|
621 | 621 |
622 let l = range(8) | 622 let l = range(8) |
623 py l = vim.bindeval('l') | 623 py l = vim.bindeval('l') |
624 py l[2:2:1] = () | 624 py l[2:2:1] = () |
625 call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l) | 625 call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l) |
626 | |
627 call AssertException(["py x = l[10:11:0]"], | |
628 \ "Vim(python):ValueError: slice step cannot be zero") | |
626 endfunc | 629 endfunc |
627 | 630 |
628 " Locked variables | 631 " Locked variables |
629 func Test_python_lockedvar() | 632 func Test_python_lockedvar() |
630 new | 633 new |
807 " Bool | 810 " Bool |
808 call assert_equal(1, pyeval("vim.bindeval('v:true')")) | 811 call assert_equal(1, pyeval("vim.bindeval('v:true')")) |
809 call assert_equal(0, pyeval("vim.bindeval('v:false')")) | 812 call assert_equal(0, pyeval("vim.bindeval('v:false')")) |
810 call assert_equal(v:none, pyeval("vim.bindeval('v:null')")) | 813 call assert_equal(v:none, pyeval("vim.bindeval('v:null')")) |
811 call assert_equal(v:none, pyeval("vim.bindeval('v:none')")) | 814 call assert_equal(v:none, pyeval("vim.bindeval('v:none')")) |
815 | |
816 " channel/job | |
817 call assert_equal(v:none, pyeval("vim.bindeval('test_null_channel()')")) | |
818 call assert_equal(v:none, pyeval("vim.bindeval('test_null_job()')")) | |
812 endfunc | 819 endfunc |
813 | 820 |
814 " threading | 821 " threading |
815 " Running pydo command (Test_pydo) before this test, stops the python thread | 822 " Running pydo command (Test_pydo) before this test, stops the python thread |
816 " from running. So this test should be run before the pydo test | 823 " from running. So this test should be run before the pydo test |
1400 call assert_equal(['First line'], pyeval('b[-10:1]')) | 1407 call assert_equal(['First line'], pyeval('b[-10:1]')) |
1401 call assert_equal(['Third line'], pyeval('b[2:10]')) | 1408 call assert_equal(['Third line'], pyeval('b[2:10]')) |
1402 call assert_equal([], pyeval('b[2:0]')) | 1409 call assert_equal([], pyeval('b[2:0]')) |
1403 call assert_equal([], pyeval('b[10:12]')) | 1410 call assert_equal([], pyeval('b[10:12]')) |
1404 call assert_equal([], pyeval('b[-10:-8]')) | 1411 call assert_equal([], pyeval('b[-10:-8]')) |
1412 call AssertException(["py x = b[0:3:0]"], | |
1413 \ "Vim(python):TypeError: sequence index must be integer, not 'slice'") | |
1414 call AssertException(["py b[0:3:0] = 'abc'"], | |
1415 \ "Vim(python):TypeError: sequence index must be integer, not 'slice'") | |
1416 call AssertException(["py x = b[{}]"], | |
1417 \ "Vim(python):TypeError: sequence index must be integer, not 'dict'") | |
1418 call AssertException(["py b[{}] = 'abc'"], | |
1419 \ "Vim(python):TypeError: sequence index must be integer, not 'dict'") | |
1420 | |
1421 " Test for getting lines using a range | |
1422 call AssertException(["py x = b.range(0,3)[0:2:0]"], | |
1423 \ "Vim(python):TypeError: sequence index must be integer, not 'slice'") | |
1424 call AssertException(["py b.range(0,3)[0:2:0] = 'abc'"], | |
1425 \ "Vim(python):TypeError: sequence index must be integer, not 'slice'") | |
1405 | 1426 |
1406 " Tests BufferAppend and BufferItem | 1427 " Tests BufferAppend and BufferItem |
1407 py cb.append(b[0]) | 1428 py cb.append(b[0]) |
1408 call assert_equal(['First line'], getbufline(bnr1, 2)) | 1429 call assert_equal(['First line'], getbufline(bnr1, 2)) |
1409 %d | 1430 %d |
1509 | 1530 |
1510 " Delete all the lines in a buffer | 1531 " Delete all the lines in a buffer |
1511 call setline(1, ['a', 'b', 'c']) | 1532 call setline(1, ['a', 'b', 'c']) |
1512 py vim.current.buffer[:] = [] | 1533 py vim.current.buffer[:] = [] |
1513 call assert_equal([''], getline(1, '$')) | 1534 call assert_equal([''], getline(1, '$')) |
1535 | |
1536 " Test for buffer marks | |
1537 call assert_equal(v:none, pyeval("vim.current.buffer.mark('r')")) | |
1514 | 1538 |
1515 " Test for modifying a 'nomodifiable' buffer | 1539 " Test for modifying a 'nomodifiable' buffer |
1516 setlocal nomodifiable | 1540 setlocal nomodifiable |
1517 call AssertException(["py vim.current.buffer[0] = 'abc'"], | 1541 call AssertException(["py vim.current.buffer[0] = 'abc'"], |
1518 \ "Vim(python):vim.error: Vim:E21: Cannot make changes, 'modifiable' is off") | 1542 \ "Vim(python):vim.error: Vim:E21: Cannot make changes, 'modifiable' is off") |
2406 del fnamemodify | 2430 del fnamemodify |
2407 EOF | 2431 EOF |
2408 call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir', | 2432 call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir', |
2409 \ 'Xfile'], getline(2, '$')) | 2433 \ 'Xfile'], getline(2, '$')) |
2410 close! | 2434 close! |
2435 call AssertException(["py vim.chdir(None)"], "Vim(python):TypeError:") | |
2411 endfunc | 2436 endfunc |
2412 | 2437 |
2413 " Test errors | 2438 " Test errors |
2414 func Test_python_errors() | 2439 func Test_python_errors() |
2415 func F() dict | 2440 func F() dict |