Mercurial > vim
annotate src/testdir/test_assert.vim @ 13594:4d55eb79178b v8.0.1669
patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
commit https://github.com/vim/vim/commit/e1bb879f49665bb828197135b80aaf72cc190073
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 6 22:58:23 2018 +0200
patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Problem: :vimgrep may add entries to the wrong quickfix list.
Solution: Use the list identifier. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 06 Apr 2018 23:00:08 +0200 |
parents | a88c5e12b860 |
children | 87012d2b17b5 |
rev | line source |
---|---|
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test that the methods used for testing work. |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
3 func Test_assert_false() |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
4 call assert_false(0) |
7951
03e716299680
commit https://github.com/vim/vim/commit/3712792637516aea7acf76a11533be1066952820
Christian Brabandt <cb@256bit.org>
parents:
7852
diff
changeset
|
5 call assert_false(v:false) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 endfunc |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
8 func Test_assert_true() |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
9 call assert_true(1) |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
10 call assert_true(123) |
7951
03e716299680
commit https://github.com/vim/vim/commit/3712792637516aea7acf76a11533be1066952820
Christian Brabandt <cb@256bit.org>
parents:
7852
diff
changeset
|
11 call assert_true(v:true) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
14 func Test_assert_equal() |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let s = 'foo' |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
16 call assert_equal('foo', s) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let n = 4 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
18 call assert_equal(4, n) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 let l = [1, 2, 3] |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
20 call assert_equal([1, 2, 3], l) |
8831
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
21 |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
22 let s = 'foo' |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
23 call assert_equal('bar', s) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
24 call assert_match("Expected 'bar' but got 'foo'", v:errors[0]) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
25 call remove(v:errors, 0) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
26 endfunc |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
27 |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
28 func Test_assert_equalfile() |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
29 call assert_equalfile('abcabc', 'xyzxyz') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
30 call assert_match("E485: Can't read file abcabc", v:errors[0]) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
31 call remove(v:errors, 0) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
32 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
33 let goodtext = ["one", "two", "three"] |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
34 call writefile(goodtext, 'Xone') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
35 call assert_equalfile('Xone', 'xyzxyz') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
36 call assert_match("E485: Can't read file xyzxyz", v:errors[0]) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
37 call remove(v:errors, 0) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
38 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
39 call writefile(goodtext, 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
40 call assert_equalfile('Xone', 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
41 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
42 call writefile([goodtext[0]], 'Xone') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
43 call assert_equalfile('Xone', 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
44 call assert_match("first file is shorter", v:errors[0]) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
45 call remove(v:errors, 0) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
46 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
47 call writefile(goodtext, 'Xone') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
48 call writefile([goodtext[0]], 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
49 call assert_equalfile('Xone', 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
50 call assert_match("second file is shorter", v:errors[0]) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
51 call remove(v:errors, 0) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
52 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
53 call writefile(['1234X89'], 'Xone') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
54 call writefile(['1234Y89'], 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
55 call assert_equalfile('Xone', 'Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
56 call assert_match("difference at byte 4", v:errors[0]) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
57 call remove(v:errors, 0) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
58 |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
59 call delete('Xone') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
60 call delete('Xtwo') |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
61 endfunc |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
62 |
8831
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
63 func Test_assert_notequal() |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
64 let n = 4 |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
65 call assert_notequal('foo', n) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
66 let s = 'foo' |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
67 call assert_notequal([1, 2, 3], s) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
68 |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
69 call assert_notequal('foo', s) |
10593
553f9b9502bc
patch 8.0.0186: confusing error message from assert_notequal()
Christian Brabandt <cb@256bit.org>
parents:
10462
diff
changeset
|
70 call assert_match("Expected not equal to 'foo'", v:errors[0]) |
8831
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
71 call remove(v:errors, 0) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 endfunc |
7412
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
73 |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
74 func Test_assert_report() |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
75 call assert_report('something is wrong') |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
76 call assert_match('something is wrong', v:errors[0]) |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
77 call remove(v:errors, 0) |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
78 endfunc |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
79 |
7675
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
80 func Test_assert_exception() |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
81 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
82 nocommand |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
83 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
84 call assert_exception('E492:') |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
85 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
86 |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
87 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
88 nocommand |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
89 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
90 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
91 " illegal argument, get NULL for error |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
92 call assert_exception([]) |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
93 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
94 call assert_exception('E730:') |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
95 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
96 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
97 endfunc |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
98 |
7852
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
99 func Test_wrong_error_type() |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
100 let save_verrors = v:errors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
101 let v:['errors'] = {'foo': 3} |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
102 call assert_equal('yes', 'no') |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
103 let verrors = v:errors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
104 let v:errors = save_verrors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
105 call assert_equal(type([]), type(verrors)) |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
106 endfunc |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
107 |
8550
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
108 func Test_compare_fail() |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
109 let s:v = {} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
110 let s:x = {"a": s:v} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
111 let s:v["b"] = s:x |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
112 let s:w = {"c": s:x, "d": ''} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
113 try |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
114 call assert_equal(s:w, '') |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
115 catch |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
116 call assert_exception('E724:') |
8749
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
117 call assert_match("Expected NULL but got ''", v:errors[0]) |
8550
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
118 call remove(v:errors, 0) |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
119 endtry |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
120 endfunc |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
121 |
8749
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
122 func Test_match() |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
123 call assert_match('^f.*b.*r$', 'foobar') |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
124 |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
125 call assert_match('bar.*foo', 'foobar') |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
126 call assert_match("Pattern 'bar.*foo' does not match 'foobar'", v:errors[0]) |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
127 call remove(v:errors, 0) |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
128 |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
129 call assert_match('bar.*foo', 'foobar', 'wrong') |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
130 call assert_match('wrong', v:errors[0]) |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
131 call remove(v:errors, 0) |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
132 endfunc |
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
133 |
8831
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
134 func Test_notmatch() |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
135 call assert_notmatch('foo', 'bar') |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
136 call assert_notmatch('^foobar$', 'foobars') |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
137 |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
138 call assert_notmatch('foo', 'foobar') |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
139 call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
140 call remove(v:errors, 0) |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
141 endfunc |
6f41d68aa68e
commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
142 |
8554
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
143 func Test_assert_fail_fails() |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
144 call assert_fails('xxx', {}) |
8749
65a5a18d3acf
commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents:
8554
diff
changeset
|
145 call assert_match("Expected {} but got 'E731:", v:errors[0]) |
8554
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
146 call remove(v:errors, 0) |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
147 endfunc |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
148 |
13272
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
149 func Test_assert_beeps() |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
150 new |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
151 call assert_beeps('normal h') |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
152 |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
153 call assert_beeps('normal 0') |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
154 call assert_match("command did not beep: normal 0", v:errors[0]) |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
155 call remove(v:errors, 0) |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
156 bwipe |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
157 endfunc |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
158 |
9636
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
159 func Test_assert_inrange() |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
160 call assert_inrange(7, 7, 7) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
161 call assert_inrange(5, 7, 5) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
162 call assert_inrange(5, 7, 6) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
163 call assert_inrange(5, 7, 7) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
164 |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
165 call assert_inrange(5, 7, 4) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
166 call assert_match("Expected range 5 - 7, but got 4", v:errors[0]) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
167 call remove(v:errors, 0) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
168 call assert_inrange(5, 7, 8) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
169 call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) |
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
170 call remove(v:errors, 0) |
10462
0d345265b1e2
commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents:
9636
diff
changeset
|
171 |
0d345265b1e2
commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents:
9636
diff
changeset
|
172 call assert_fails('call assert_inrange(1, 1)', 'E119:') |
9636
ccbb8e393d80
commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents:
8831
diff
changeset
|
173 endfunc |
8550
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
174 |
10728
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
175 func Test_assert_with_msg() |
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
176 call assert_equal('foo', 'bar', 'testing') |
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
177 call assert_match("testing: Expected 'foo' but got 'bar'", v:errors[0]) |
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
178 call remove(v:errors, 0) |
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
179 endfunc |
8ba322dad776
patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents:
10593
diff
changeset
|
180 |
11105
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
181 func Test_override() |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
182 call test_override('char_avail', 1) |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
183 call test_override('redraw', 1) |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
184 call test_override('ALL', 0) |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
185 call assert_fails("call test_override('xxx', 1)", 'E475') |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
186 call assert_fails("call test_override('redraw', 'yes')", 'E474') |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
187 endfunc |
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
10728
diff
changeset
|
188 |
7412
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
189 func Test_user_is_happy() |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
190 smile |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
191 sleep 300m |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
192 endfunc |