comparison src/testdir/test_python3.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
796 796
797 let l = range(8) 797 let l = range(8)
798 py3 l = vim.bindeval('l') 798 py3 l = vim.bindeval('l')
799 py3 l[2:2:1] = () 799 py3 l[2:2:1] = ()
800 call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l) 800 call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l)
801
802 call AssertException(["py3 x = l[10:11:0]"],
803 \ "Vim(py3):ValueError: slice step cannot be zero")
801 endfunc 804 endfunc
802 805
803 " Locked variables 806 " Locked variables
804 func Test_python3_lockedvar() 807 func Test_python3_lockedvar()
805 new 808 new
985 " Bool 988 " Bool
986 call assert_equal(1, py3eval("vim.bindeval('v:true')")) 989 call assert_equal(1, py3eval("vim.bindeval('v:true')"))
987 call assert_equal(0, py3eval("vim.bindeval('v:false')")) 990 call assert_equal(0, py3eval("vim.bindeval('v:false')"))
988 call assert_equal(v:none, py3eval("vim.bindeval('v:null')")) 991 call assert_equal(v:none, py3eval("vim.bindeval('v:null')"))
989 call assert_equal(v:none, py3eval("vim.bindeval('v:none')")) 992 call assert_equal(v:none, py3eval("vim.bindeval('v:none')"))
993
994 " channel/job
995 call assert_equal(v:none, py3eval("vim.bindeval('test_null_channel()')"))
996 call assert_equal(v:none, py3eval("vim.bindeval('test_null_job()')"))
990 endfunc 997 endfunc
991 998
992 " threading 999 " threading
993 " Running py3do command (Test_pydo) before this test, stops the python thread 1000 " Running py3do command (Test_pydo) before this test, stops the python thread
994 " from running. So this test should be run before the pydo test 1001 " from running. So this test should be run before the pydo test
1578 call assert_equal(['First line'], py3eval('b[-10:1]')) 1585 call assert_equal(['First line'], py3eval('b[-10:1]'))
1579 call assert_equal(['Third line'], py3eval('b[2:10]')) 1586 call assert_equal(['Third line'], py3eval('b[2:10]'))
1580 call assert_equal([], py3eval('b[2:0]')) 1587 call assert_equal([], py3eval('b[2:0]'))
1581 call assert_equal([], py3eval('b[10:12]')) 1588 call assert_equal([], py3eval('b[10:12]'))
1582 call assert_equal([], py3eval('b[-10:-8]')) 1589 call assert_equal([], py3eval('b[-10:-8]'))
1590 call AssertException(["py3 x = b[0:3:0]"],
1591 \ 'Vim(py3):ValueError: slice step cannot be zero')
1592 call AssertException(["py3 b[0:3:0] = 'abc'"],
1593 \ 'Vim(py3):ValueError: slice step cannot be zero')
1594 call AssertException(["py3 x = b[{}]"],
1595 \ 'Vim(py3):TypeError: index must be int or slice, not dict')
1596 call AssertException(["py3 b[{}] = 'abc'"],
1597 \ 'Vim(py3):TypeError: index must be int or slice, not dict')
1598
1599 " Test for getting lines using a range
1600 call AssertException(["py3 x = b.range(0,3)[0:2:0]"],
1601 \ "Vim(py3):ValueError: slice step cannot be zero")
1602 call AssertException(["py3 b.range(0,3)[0:2:0] = 'abc'"],
1603 \ "Vim(py3):ValueError: slice step cannot be zero")
1583 1604
1584 " Tests BufferAppend and BufferItem 1605 " Tests BufferAppend and BufferItem
1585 py3 cb.append(b[0]) 1606 py3 cb.append(b[0])
1586 call assert_equal(['First line'], getbufline(bnr1, 2)) 1607 call assert_equal(['First line'], getbufline(bnr1, 2))
1587 %d 1608 %d
1687 1708
1688 " Delete all the lines in a buffer 1709 " Delete all the lines in a buffer
1689 call setline(1, ['a', 'b', 'c']) 1710 call setline(1, ['a', 'b', 'c'])
1690 py3 vim.current.buffer[:] = [] 1711 py3 vim.current.buffer[:] = []
1691 call assert_equal([''], getline(1, '$')) 1712 call assert_equal([''], getline(1, '$'))
1713
1714 " Test for buffer marks
1715 call assert_equal(v:none, py3eval("vim.current.buffer.mark('r')"))
1692 1716
1693 " Test for modifying a 'nomodifiable' buffer 1717 " Test for modifying a 'nomodifiable' buffer
1694 setlocal nomodifiable 1718 setlocal nomodifiable
1695 call AssertException(["py3 vim.current.buffer[0] = 'abc'"], 1719 call AssertException(["py3 vim.current.buffer[0] = 'abc'"],
1696 \ "Vim(py3):vim.error: Vim:E21: Cannot make changes, 'modifiable' is off") 1720 \ "Vim(py3):vim.error: Vim:E21: Cannot make changes, 'modifiable' is off")
2576 del fnamemodify 2600 del fnamemodify
2577 EOF 2601 EOF
2578 call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile', 2602 call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile',
2579 \"b'testdir'", 'Xfile'], getline(2, '$')) 2603 \"b'testdir'", 'Xfile'], getline(2, '$'))
2580 close! 2604 close!
2605 call AssertException(["py3 vim.chdir(None)"], "Vim(py3):TypeError:")
2581 endfunc 2606 endfunc
2582 2607
2583 " Test errors 2608 " Test errors
2584 func Test_python3_errors() 2609 func Test_python3_errors()
2585 func F() dict 2610 func F() dict