annotate src/testdir/test_assert.vim @ 31039:220215b8a7c9 v9.0.0854

patch 9.0.0854: no proper test for what 9.0.0846 fixes Commit: https://github.com/vim/vim/commit/7265851b2b4e5a63c0a02a9057dee237502ee557 Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Nov 10 13:21:34 2022 +0000 patch 9.0.0854: no proper test for what 9.0.0846 fixes Problem: No proper test for what 9.0.0846 fixes. Solution: Run test in a terminal so that the hit-enter prompt can show up. (closes #11523)
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Nov 2022 14:30:04 +0100
parents 9a5e540510cf
children dbec60b8c253
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
31039
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
3 source check.vim
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
4 source term_util.vim
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
5
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
6 func Test_assert_false()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
7 call assert_equal(0, assert_false(0))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
8 call assert_equal(0, assert_false(v:false))
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
9 call assert_equal(0, v:false->assert_false())
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
10
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
11 call assert_equal(1, assert_false(123))
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
12 call assert_match("Expected 'False' but got 123", v:errors[0])
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
13 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
14
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
15 call assert_equal(1, 123->assert_false())
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
16 call assert_match("Expected 'False' but got 123", v:errors[0])
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
17 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 endfunc
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
20 func Test_assert_true()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
21 call assert_equal(0, assert_true(1))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
22 call assert_equal(0, assert_true(123))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
23 call assert_equal(0, assert_true(v:true))
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
24 call assert_equal(0, v:true->assert_true())
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
25
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
26 call assert_equal(1, assert_true(0))
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
27 call assert_match("Expected 'True' but got 0", v:errors[0])
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
28 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
29
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
30 call assert_equal(1, 0->assert_true())
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
31 call assert_match("Expected 'True' but got 0", v:errors[0])
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
32 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endfunc
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
35 func Test_assert_equal()
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 let s = 'foo'
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
37 call assert_equal(0, assert_equal('foo', s))
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 let n = 4
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
39 call assert_equal(0, assert_equal(4, n))
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 let l = [1, 2, 3]
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
41 call assert_equal(0, assert_equal([1, 2, 3], l))
19966
c0eb073378e7 patch 8.2.0539: comparing two NULL list fails
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
42 call assert_equal(test_null_list(), test_null_list())
c0eb073378e7 patch 8.2.0539: comparing two NULL list fails
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
43 call assert_equal(test_null_list(), [])
c0eb073378e7 patch 8.2.0539: comparing two NULL list fails
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
44 call assert_equal([], test_null_list())
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
45
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
46 let s = 'foo'
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
47 call assert_equal(1, assert_equal('bar', s))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
48 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
49 call remove(v:errors, 0)
15623
e3ddffe48d17 patch 8.1.0819: a failed assert with a long string is hard to read
Bram Moolenaar <Bram@vim.org>
parents: 14897
diff changeset
50
e3ddffe48d17 patch 8.1.0819: a failed assert with a long string is hard to read
Bram Moolenaar <Bram@vim.org>
parents: 14897
diff changeset
51 call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX')
e3ddffe48d17 patch 8.1.0819: a failed assert with a long string is hard to read
Bram Moolenaar <Bram@vim.org>
parents: 14897
diff changeset
52 call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0])
e3ddffe48d17 patch 8.1.0819: a failed assert with a long string is hard to read
Bram Moolenaar <Bram@vim.org>
parents: 14897
diff changeset
53 call remove(v:errors, 0)
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
54
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
55 " special characters are escaped
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
56 call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x')
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
57 call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''x''', v:errors[0])
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
58 call remove(v:errors, 0)
27742
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
59
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
60 " many composing characters are handled properly
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
61 call setline(1, ' ')
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
62 norm 100grƯ€
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
63 call assert_equal(1, getline(1))
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
64 call assert_match("Expected 1 but got '.* occurs 100 times]'", v:errors[0])
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
65 call remove(v:errors, 0)
3b2c75c0a7ab patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
66 bwipe!
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
67 endfunc
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
68
20834
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
69 func Test_assert_equal_dict()
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
70 call assert_equal(0, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 1}))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
71
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
72 call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 3}))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
73 call assert_match("Expected {'one': 1} but got {'one': 3} - 1 equal item omitted", v:errors[0])
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
74 call remove(v:errors, 0)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
75
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
76 call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 22, one: 11}))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
77 call assert_match("Expected {'one': 1, 'two': 2} but got {'one': 11, 'two': 22}", v:errors[0])
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
78 call remove(v:errors, 0)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
79
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
80 call assert_equal(1, assert_equal(#{}, #{two: 2, one: 1}))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
81 call assert_match("Expected {} but got {'one': 1, 'two': 2}", v:errors[0])
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
82 call remove(v:errors, 0)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
83
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
84 call assert_equal(1, assert_equal(#{two: 2, one: 1}, #{}))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
85 call assert_match("Expected {'one': 1, 'two': 2} but got {}", v:errors[0])
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
86 call remove(v:errors, 0)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
87 endfunc
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
88
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
89 func Test_assert_equalfile()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
90 call assert_equal(1, assert_equalfile('abcabc', 'xyzxyz'))
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
91 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
92 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
93
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
94 let goodtext = ["one", "two", "three"]
30089
0a50e536de81 patch 9.0.0380: deleting files in tests is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 30043
diff changeset
95 call writefile(goodtext, 'Xone', 'D')
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
96 call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz'))
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
97 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
98 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
99
30089
0a50e536de81 patch 9.0.0380: deleting files in tests is a hassle
Bram Moolenaar <Bram@vim.org>
parents: 30043
diff changeset
100 call writefile(goodtext, 'Xtwo', 'D')
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
101 call assert_equal(0, assert_equalfile('Xone', 'Xtwo'))
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
102
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
103 call writefile([goodtext[0]], 'Xone')
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
104 call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
105 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
106 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
107
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
108 call writefile(goodtext, 'Xone')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
109 call writefile([goodtext[0]], 'Xtwo')
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
110 call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
111 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
112 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
113
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
114 call writefile(['1234X89'], 'Xone')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
115 call writefile(['1234Y89'], 'Xtwo')
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
116 call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
20691
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
117 call assert_match('difference at byte 4, line 1 after "1234X" vs "1234Y"', v:errors[0])
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
118 call remove(v:errors, 0)
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
119
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
120 call writefile([repeat('x', 234) .. 'X'], 'Xone')
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
121 call writefile([repeat('x', 234) .. 'Y'], 'Xtwo')
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
122 call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
123 let xes = repeat('x', 134)
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
124 call assert_match('difference at byte 234, line 1 after "' .. xes .. 'X" vs "' .. xes .. 'Y"', v:errors[0])
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
125 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
126
20679
1af1d8ff2aa8 patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents: 19966
diff changeset
127 call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
20691
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
128 call assert_match("a message: difference at byte 234, line 1 after", v:errors[0])
20679
1af1d8ff2aa8 patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents: 19966
diff changeset
129 call remove(v:errors, 0)
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
130 endfunc
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
131
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
132 func Test_assert_notequal()
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
133 let n = 4
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
134 call assert_equal(0, assert_notequal('foo', n))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
135 let s = 'foo'
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
136 call assert_equal(0, assert_notequal([1, 2, 3], s))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
137
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
138 call assert_equal(1, 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
139 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
140 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 endfunc
7412
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
142
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
143 func Test_assert_report()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
144 call assert_equal(1, assert_report('something is wrong'))
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
145 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
146 call remove(v:errors, 0)
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
147 call assert_equal(1, 'also wrong'->assert_report())
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
148 call assert_match('also wrong', v:errors[0])
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
149 call remove(v:errors, 0)
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
150 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
151
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
152 func Test_assert_exception()
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
153 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
154 nocommand
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
155 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
156 call assert_equal(0, assert_exception('E492:'))
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
157 endtry
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
158
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
159 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
160 nocommand
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
161 catch
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
162 call assert_equal(1, assert_exception('E12345:'))
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
163 endtry
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
164 call assert_match("Expected 'E12345:' but got 'Vim:E492: ", v:errors[0])
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
165 call remove(v:errors, 0)
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
166
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
167 try
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
168 nocommand
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
169 catch
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
170 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
171 " illegal argument, get NULL for error
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
172 call assert_equal(1, assert_exception([]))
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
173 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
174 call assert_equal(0, assert_exception('E730:'))
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
175 endtry
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
176 endtry
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
177
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
178 call assert_equal(1, assert_exception('E492:'))
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
179 call assert_match('v:exception is not set', v:errors[0])
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
180 call remove(v:errors, 0)
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
181 endfunc
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
182
7852
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
183 func Test_wrong_error_type()
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
184 let save_verrors = v:errors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
185 let v:['errors'] = {'foo': 3}
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
186 call assert_equal('yes', 'no')
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
187 let verrors = v:errors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
188 let v:errors = save_verrors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
189 call assert_equal(type([]), type(verrors))
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
190 endfunc
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
191
8550
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
192 func Test_compare_fail()
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
193 let s:v = {}
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
194 let s:x = {"a": s:v}
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
195 let s:v["b"] = s:x
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
196 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
197 try
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
198 call assert_equal(s:w, '')
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
199 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
200 call assert_equal(0, assert_exception('E724:'))
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
201 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
202 call remove(v:errors, 0)
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
203 endtry
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
204 endfunc
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
205
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
206 func Test_match()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
207 call assert_equal(0, assert_match('^f.*b.*r$', 'foobar'))
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
208
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
209 call assert_equal(1, assert_match('bar.*foo', 'foobar'))
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
210 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
211 call remove(v:errors, 0)
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
212
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
213 call assert_equal(1, assert_match('bar.*foo', 'foobar', 'wrong'))
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
214 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
215 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
216
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
217 call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong'))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
218 call assert_match('wrong', v:errors[0])
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
219 call remove(v:errors, 0)
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
220 endfunc
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
221
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
222 func Test_notmatch()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
223 call assert_equal(0, assert_notmatch('foo', 'bar'))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
224 call assert_equal(0, assert_notmatch('^foobar$', 'foobars'))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
225
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
226 call assert_equal(1, assert_notmatch('foo', 'foobar'))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
227 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
228 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
229
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
230 call assert_equal(1, 'foobar'->assert_notmatch('foo'))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
231 call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0])
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
232 call remove(v:errors, 0)
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
233 endfunc
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
234
8554
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
235 func Test_assert_fail_fails()
21267
7833afe1c66e patch 8.2.1184: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 20834
diff changeset
236 call assert_equal(1, assert_fails('xxx', 'E12345'))
7833afe1c66e patch 8.2.1184: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 20834
diff changeset
237 call assert_match("Expected 'E12345' but got 'E492:", v:errors[0])
8554
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
238 call remove(v:errors, 0)
14897
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
239
21267
7833afe1c66e patch 8.2.1184: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 20834
diff changeset
240 call assert_equal(1, assert_fails('xxx', 'E9876', 'stupid'))
7833afe1c66e patch 8.2.1184: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 20834
diff changeset
241 call assert_match("stupid: Expected 'E9876' but got 'E492:", v:errors[0])
14897
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
242 call remove(v:errors, 0)
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
243
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
244 call assert_equal(1, assert_fails('xxx', ['E9876']))
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
245 call assert_match("Expected 'E9876' but got 'E492:", v:errors[0])
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
246 call remove(v:errors, 0)
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
247
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
248 call assert_equal(1, assert_fails('xxx', ['E492:', 'E9876']))
22810
2d05dd71aac3 patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
249 call assert_match("Expected 'E9876' but got 'E492:", v:errors[0])
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
250 call remove(v:errors, 0)
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
251
14897
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
252 call assert_equal(1, assert_fails('echo', '', 'echo command'))
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
253 call assert_match("command did not fail: echo command", v:errors[0])
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
254 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
255
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
256 call assert_equal(1, 'echo'->assert_fails('', 'echo command'))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
257 call assert_match("command did not fail: echo command", v:errors[0])
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
258 call remove(v:errors, 0)
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
259
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
260 try
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
261 call assert_equal(1, assert_fails('xxx', []))
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
262 catch
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
263 let exp = v:exception
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
264 endtry
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22165
diff changeset
265 call assert_match("E856: \"assert_fails()\" second argument", exp)
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
266
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
267 try
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
268 call assert_equal(1, assert_fails('xxx', ['1', '2', '3']))
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
269 catch
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
270 let exp = v:exception
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
271 endtry
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22165
diff changeset
272 call assert_match("E856: \"assert_fails()\" second argument", exp)
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
273
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
274 try
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
275 call assert_equal(1, assert_fails('xxx', test_null_list()))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
276 catch
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
277 let exp = v:exception
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
278 endtry
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
279 call assert_match("E856: \"assert_fails()\" second argument", exp)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
280
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
281 try
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
282 call assert_equal(1, assert_fails('xxx', []))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
283 catch
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
284 let exp = v:exception
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
285 endtry
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
286 call assert_match("E856: \"assert_fails()\" second argument", exp)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
287
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
288 try
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
289 call assert_equal(1, assert_fails('xxx', #{one: 1}))
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
290 catch
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
291 let exp = v:exception
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21267
diff changeset
292 endtry
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
293 call assert_match("E1222: String or List required for argument 2", exp)
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
294
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
295 try
30136
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
296 call assert_equal(0, assert_fails('xxx', [#{one: 1}]))
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
297 catch
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
298 let exp = v:exception
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
299 endtry
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
300 call assert_match("E731: Using a Dictionary as a String", exp)
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
301
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
302 let exp = ''
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
303 try
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
304 call assert_equal(0, assert_fails('xxx', ['E492', #{one: 1}]))
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
305 catch
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
306 let exp = v:exception
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
307 endtry
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
308 call assert_match("E731: Using a Dictionary as a String", exp)
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
309
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
310 try
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
311 call assert_equal(1, assert_fails('xxx', 'E492', '', 'burp'))
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
312 catch
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
313 let exp = v:exception
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
314 endtry
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24998
diff changeset
315 call assert_match("E1210: Number required for argument 4", exp)
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
316
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
317 try
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
318 call assert_equal(1, assert_fails('xxx', 'E492', '', 54, 123))
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
319 catch
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
320 let exp = v:exception
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
321 endtry
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24998
diff changeset
322 call assert_match("E1174: String required for argument 5", exp)
29746
567b5a2a1884 patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents: 27742
diff changeset
323
30136
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
324 call assert_equal(1, assert_fails('c0', ['', '\(.\)\1']))
5380551172aa patch 9.0.0404: crash when passing invalid arguments to assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 30089
diff changeset
325 call assert_match("Expected '\\\\\\\\(.\\\\\\\\)\\\\\\\\1' but got 'E939: Positive count required: c0': c0", v:errors[0])
29746
567b5a2a1884 patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents: 27742
diff changeset
326 call remove(v:errors, 0)
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
327
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
328 " Test for matching the line number and the script name in an error message
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
329 call writefile(['', 'call Xnonexisting()'], 'Xassertfails.vim', 'D')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
330 call assert_fails('source Xassertfails.vim', 'E117:', '', 10)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
331 call assert_match("Expected 10 but got 2", v:errors[0])
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
332 call remove(v:errors, 0)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
333 call assert_fails('source Xassertfails.vim', 'E117:', '', 2, 'Xabc')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
334 call assert_match("Expected 'Xabc' but got .*Xassertfails.vim", v:errors[0])
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
335 call remove(v:errors, 0)
8554
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
336 endfunc
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
337
17322
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
338 func Test_assert_fails_in_try_block()
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
339 try
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
340 call assert_equal(0, assert_fails('throw "error"'))
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
341 endtry
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
342 endfunc
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
343
31039
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
344 " Test that assert_fails() in a timer does not cause a hit-enter prompt.
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
345 " Requires using a terminal, in regular tests the hit-enter prompt won't be
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
346 " triggered.
31022
9a5e540510cf patch 9.0.0846: using assert_fails() may cause hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
347 func Test_assert_fails_in_timer()
31039
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
348 CheckRunVimInTerminal
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
349
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
350 let buf = RunVimInTerminal('', {'rows': 6})
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
351 let cmd = ":call timer_start(0, {-> assert_fails('call', 'E471:')})"
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
352 call term_sendkeys(buf, cmd)
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
353 call WaitForAssert({-> assert_equal(cmd, term_getline(buf, 6))})
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
354 call term_sendkeys(buf, "\<CR>")
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
355 call TermWait(buf, 100)
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
356 call assert_match('E471: Argument required', term_getline(buf, 6))
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
357
220215b8a7c9 patch 9.0.0854: no proper test for what 9.0.0846 fixes
Bram Moolenaar <Bram@vim.org>
parents: 31022
diff changeset
358 call StopVimInTerminal(buf)
31022
9a5e540510cf patch 9.0.0846: using assert_fails() may cause hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
359 endfunc
9a5e540510cf patch 9.0.0846: using assert_fails() may cause hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
360
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
361 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
362 new
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
363 call assert_equal(0, assert_beeps('normal h'))
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
364
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
365 call assert_equal(1, assert_beeps('normal 0'))
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
366 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
367 call remove(v:errors, 0)
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
368
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
369 call assert_equal(0, 'normal h'->assert_beeps())
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
370 call assert_equal(1, 'normal 0'->assert_beeps())
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
371 call assert_match("command did not beep: normal 0", v:errors[0])
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
372 call remove(v:errors, 0)
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
373
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
374 bwipe
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
375 endfunc
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
376
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
377 func Test_assert_nobeep()
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
378 call assert_equal(1, assert_nobeep('normal! cr'))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
379 call assert_match("command did beep: normal! cr", v:errors[0])
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
380 call remove(v:errors, 0)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
381 endfunc
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
382
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
383 func Test_assert_inrange()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
384 call assert_equal(0, assert_inrange(7, 7, 7))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
385 call assert_equal(0, assert_inrange(5, 7, 5))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
386 call assert_equal(0, assert_inrange(5, 7, 6))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
387 call assert_equal(0, assert_inrange(5, 7, 7))
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
388
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
389 call assert_equal(1, assert_inrange(5, 7, 4))
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
390 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
391 call remove(v:errors, 0)
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
392 call assert_equal(1, assert_inrange(5, 7, 8))
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
393 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
394 call remove(v:errors, 0)
10462
0d345265b1e2 commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
395
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
396 call assert_equal(0, 5->assert_inrange(5, 7))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
397 call assert_equal(0, 7->assert_inrange(5, 7))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
398 call assert_equal(1, 8->assert_inrange(5, 7))
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
399 call assert_match("Expected range 5 - 7, but got 8", v:errors[0])
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
400 call remove(v:errors, 0)
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
401
10462
0d345265b1e2 commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
402 call assert_fails('call assert_inrange(1, 1)', 'E119:')
15904
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
403
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
404 call assert_equal(0, assert_inrange(7.0, 7, 7))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
405 call assert_equal(0, assert_inrange(7, 7.0, 7))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
406 call assert_equal(0, assert_inrange(7, 7, 7.0))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
407 call assert_equal(0, assert_inrange(5, 7, 5.0))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
408 call assert_equal(0, assert_inrange(5, 7, 6.0))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
409 call assert_equal(0, assert_inrange(5, 7, 7.0))
15904
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
410
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
411 call assert_equal(1, assert_inrange(5, 7, 4.0))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
412 call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0])
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
413 call remove(v:errors, 0)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
414 call assert_equal(1, assert_inrange(5, 7, 8.0))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
415 call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 30136
diff changeset
416 call remove(v:errors, 0)
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
417
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
418 " Use a custom message
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
419 call assert_equal(1, assert_inrange(5, 7, 8.0, "Higher"))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
420 call assert_match("Higher", v:errors[0])
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
421 call remove(v:errors, 0)
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
422
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
423 " Invalid arguments
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
424 call assert_fails("call assert_inrange([], 2, 3)", 'E1219:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
425 call assert_fails("call assert_inrange(1, [], 3)", 'E1219:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
426 call assert_fails("call assert_inrange(1, 2, [])", 'E1219:')
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
427 endfunc
8550
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
428
10728
8ba322dad776 patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents: 10593
diff changeset
429 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
430 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
431 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
432 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
433 endfunc
8ba322dad776 patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents: 10593
diff changeset
434
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
435 func Test_override()
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
436 call test_override('char_avail', 1)
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
437 eval 1->test_override('redraw')
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
438 call test_override('ALL', 0)
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
439 call assert_fails("call test_override('xxx', 1)", 'E475:')
30043
fd855ad74887 patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents: 29746
diff changeset
440 call assert_fails("call test_override('redraw', 'yes')", 'E1210:')
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
441 endfunc
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
442
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
443 func Test_mouse_position()
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
444 let save_mouse = &mouse
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
445 set mouse=a
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
446 new
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
447 call setline(1, ['line one', 'line two'])
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
448 call assert_equal([0, 1, 1, 0], getpos('.'))
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
449 call test_setmouse(1, 5)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
450 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
451 call assert_equal([0, 1, 5, 0], getpos('.'))
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
452 call test_setmouse(2, 20)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
453 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
454 call assert_equal([0, 2, 8, 0], getpos('.'))
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
455 call test_setmouse(5, 1)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
456 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
457 call assert_equal([0, 2, 1, 0], getpos('.'))
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22810
diff changeset
458 call assert_fails('call test_setmouse("", 2)', 'E474:')
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22810
diff changeset
459 call assert_fails('call test_setmouse(1, "")', 'E474:')
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
460 bwipe!
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
461 let &mouse = save_mouse
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
462 endfunc
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
463
7412
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
464 func Test_user_is_happy()
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
465 smile
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
466 sleep 300m
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
467 endfunc
14053
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
468
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
469 " Test for the test_alloc_fail() function
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
470 func Test_test_alloc_fail()
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
471 call assert_fails('call test_alloc_fail([], 1, 1)', 'E474:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
472 call assert_fails('call test_alloc_fail(10, [], 1)', 'E474:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
473 call assert_fails('call test_alloc_fail(10, 1, [])', 'E474:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
474 call assert_fails('call test_alloc_fail(999999, 1, 1)', 'E474:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
475 endfunc
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
476
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
477 " Test for the test_option_not_set() function
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
478 func Test_test_option_not_set()
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
479 call assert_fails('call test_option_not_set("Xinvalidopt")', 'E475:')
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
480 endfunc
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
481
14053
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
482 " Must be last.
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
483 func Test_zz_quit_detected()
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
484 " Verify that if a test function ends Vim the test script detects this.
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
485 quit
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
486 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21297
diff changeset
487
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21297
diff changeset
488 " vim: shiftwidth=2 sts=2 expandtab