Mercurial > vim
annotate src/testdir/test_eval_stuff.vim @ 15468:1550cc188ff6 v8.1.0742
patch 8.1.0742: not all Blob operations are tested
commit https://github.com/vim/vim/commit/05500ece6282407f9f7227aaf564e24147326863
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 19:10:33 2019 +0100
patch 8.1.0742: not all Blob operations are tested
Problem: Not all Blob operations are tested.
Solution: Add more testing for Blob.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 19:15:06 +0100 |
parents | f01eb1aed348 |
children | e26caeb30026 |
rev | line source |
---|---|
13096
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for various eval things. |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 function s:foo() abort |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 try |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 return [] == 0 |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 catch |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 return 1 |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 endtry |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 endfunction |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 func Test_catch_return_with_error() |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_equal(1, s:foo()) |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 endfunc |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
14 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
15 func Test_nocatch_restore_silent_emsg() |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
16 silent! try |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
17 throw 1 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
18 catch |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
19 endtry |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
20 echoerr 'wrong' |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
21 let c1 = nr2char(screenchar(&lines, 1)) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
22 let c2 = nr2char(screenchar(&lines, 2)) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
23 let c3 = nr2char(screenchar(&lines, 3)) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
24 let c4 = nr2char(screenchar(&lines, 4)) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
25 let c5 = nr2char(screenchar(&lines, 5)) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
26 call assert_equal('wrong', c1 . c2 . c3 . c4 . c5) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13096
diff
changeset
|
27 endfunc |
13672
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
28 |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
29 func Test_mkdir_p() |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
30 call mkdir('Xmkdir/nested', 'p') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
31 call assert_true(isdirectory('Xmkdir/nested')) |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
32 try |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
33 " Trying to make existing directories doesn't error |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
34 call mkdir('Xmkdir', 'p') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
35 call mkdir('Xmkdir/nested', 'p') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
36 catch /E739:/ |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
37 call assert_report('mkdir(..., "p") failed for an existing directory') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
38 endtry |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
39 " 'p' doesn't suppress real errors |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
40 call writefile([], 'Xfile') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
41 call assert_fails('call mkdir("Xfile", "p")', 'E739') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
42 call delete('Xfile') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
43 call delete('Xmkdir', 'rf') |
4a1efd1a6018
patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
44 endfunc |
14714
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
45 |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
46 func Test_line_continuation() |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
47 let array = [5, |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
48 "\ ignore this |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
49 \ 6, |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
50 "\ more to ignore |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
51 "\ more moreto ignore |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
52 \ ] |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
53 "\ and some more |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
54 call assert_equal([5, 6], array) |
bdbb049c2aa8
patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents:
13672
diff
changeset
|
55 endfunc |
15107
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
56 |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
57 func Test_E963() |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
58 " These commands used to cause an internal error prior to vim 8.1.0563 |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
59 let v_e = v:errors |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
60 let v_o = v:oldfiles |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
61 call assert_fails("let v:errors=''", 'E963:') |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
62 call assert_equal(v_e, v:errors) |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
63 call assert_fails("let v:oldfiles=''", 'E963:') |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
64 call assert_equal(v_o, v:oldfiles) |
6344377dc7dc
patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents:
14714
diff
changeset
|
65 endfunc |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
66 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
67 func Test_for_invalid() |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
68 call assert_fails("for x in 99", 'E714:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
69 call assert_fails("for x in 'asdf'", 'E714:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
70 call assert_fails("for x in {'a': 9}", 'E714:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15107
diff
changeset
|
71 endfunc |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
72 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
73 func Test_readfile_binary() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
74 new |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
75 call setline(1, ['one', 'two', 'three']) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
76 setlocal ff=dos |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
77 write XReadfile |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
78 let lines = readfile('XReadfile') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
79 call assert_equal(['one', 'two', 'three'], lines) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
80 let lines = readfile('XReadfile', '', 2) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
81 call assert_equal(['one', 'two'], lines) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
82 let lines = readfile('XReadfile', 'b') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
83 call assert_equal(["one\r", "two\r", "three\r", ""], lines) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
84 let lines = readfile('XReadfile', 'b', 2) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
85 call assert_equal(["one\r", "two\r"], lines) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
86 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
87 bwipe! |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
88 call delete('XReadfile') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
89 endfunc |