Mercurial > vim
comparison src/testdir/test_functions.vim @ 20120:16460964c304 v8.2.0615
patch 8.2.0615: regexp benchmark stest is old style
Commit: https://github.com/vim/vim/commit/ad48e6c1590842ab6d48e6caba3e9250734dae27
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 21 22:19:45 2020 +0200
patch 8.2.0615: regexp benchmark stest is old style
Problem: Regexp benchmark stest is old style.
Solution: Make it a new style test. Fix using a NULL list. Add more tests.
(Yegappan Lakshmanan, closes #5963)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 21 Apr 2020 22:30:03 +0200 |
parents | e82996ad131f |
children | 49694eceaa55 |
comparison
equal
deleted
inserted
replaced
20119:35c4224dc232 | 20120:16460964c304 |
---|---|
792 bwipe! | 792 bwipe! |
793 iunmap <F2> | 793 iunmap <F2> |
794 set complete& | 794 set complete& |
795 endfunc | 795 endfunc |
796 | 796 |
797 " Test for append() | |
797 func Test_append() | 798 func Test_append() |
798 enew! | 799 enew! |
799 split | 800 split |
800 call append(0, ["foo"]) | 801 call append(0, ["foo"]) |
802 call append(1, []) | |
803 call append(1, test_null_list()) | |
804 call assert_equal(['foo', ''], getline(1, '$')) | |
801 split | 805 split |
802 only | 806 only |
803 undo | 807 undo |
808 undo | |
804 | 809 |
805 " Using $ instead of '$' must give an error | 810 " Using $ instead of '$' must give an error |
806 call assert_fails("call append($, 'foobar')", 'E116:') | 811 call assert_fails("call append($, 'foobar')", 'E116:') |
812 endfunc | |
813 | |
814 " Test for setline() | |
815 func Test_setline() | |
816 new | |
817 call setline(0, ["foo"]) | |
818 call setline(0, []) | |
819 call setline(0, test_null_list()) | |
820 call setline(1, ["bar"]) | |
821 call setline(1, []) | |
822 call setline(1, test_null_list()) | |
823 call setline(2, []) | |
824 call setline(2, test_null_list()) | |
825 call setline(3, []) | |
826 call setline(3, test_null_list()) | |
827 call setline(2, ["baz"]) | |
828 call assert_equal(['bar', 'baz'], getline(1, '$')) | |
829 close! | |
807 endfunc | 830 endfunc |
808 | 831 |
809 func Test_getbufvar() | 832 func Test_getbufvar() |
810 let bnr = bufnr('%') | 833 let bnr = bufnr('%') |
811 let b:var_num = '1234' | 834 let b:var_num = '1234' |
911 call assert_fails("let x=match('vim', [])", 'E730:') | 934 call assert_fails("let x=match('vim', [])", 'E730:') |
912 call assert_equal(3, match(['a', 'b', 'c', 'a'], 'a', 1)) | 935 call assert_equal(3, match(['a', 'b', 'c', 'a'], 'a', 1)) |
913 call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5)) | 936 call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5)) |
914 call assert_equal(4, match('testing', 'ing', -1)) | 937 call assert_equal(4, match('testing', 'ing', -1)) |
915 call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:') | 938 call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:') |
939 call assert_equal(-1, match(test_null_list(), 2)) | |
916 endfunc | 940 endfunc |
917 | 941 |
918 func Test_matchend() | 942 func Test_matchend() |
919 call assert_equal(7, matchend('testing', 'ing')) | 943 call assert_equal(7, matchend('testing', 'ing')) |
920 call assert_equal(7, 'testing'->matchend('ing', 2)) | 944 call assert_equal(7, 'testing'->matchend('ing', 2)) |
1794 func Test_call() | 1818 func Test_call() |
1795 call assert_equal(3, call('len', [123])) | 1819 call assert_equal(3, call('len', [123])) |
1796 call assert_equal(3, 'len'->call([123])) | 1820 call assert_equal(3, 'len'->call([123])) |
1797 call assert_fails("call call('len', 123)", 'E714:') | 1821 call assert_fails("call call('len', 123)", 'E714:') |
1798 call assert_equal(0, call('', [])) | 1822 call assert_equal(0, call('', [])) |
1823 call assert_equal(0, call('len', test_null_list())) | |
1799 | 1824 |
1800 function Mylen() dict | 1825 function Mylen() dict |
1801 return len(self.data) | 1826 return len(self.data) |
1802 endfunction | 1827 endfunction |
1803 let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} | 1828 let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} |
1960 | 1985 |
1961 " complete() | 1986 " complete() |
1962 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>" | 1987 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>" |
1963 " complete_info() | 1988 " complete_info() |
1964 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>" | 1989 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>" |
1965 call assert_fails('call complete(1, ["a"])', 'E785:') | |
1966 | 1990 |
1967 " copy() | 1991 " copy() |
1968 call assert_equal([1, 2, 3], copy(range(1, 3))) | 1992 call assert_equal([1, 2, 3], copy(range(1, 3))) |
1969 | 1993 |
1970 " count() | 1994 " count() |