annotate src/testdir/test_assert.vim @ 17984:2ea47dee7ddd v8.1.1988

patch 8.1.1988: :startinsert! does not work the same way as "A" Commit: https://github.com/vim/vim/commit/8d3b51084a5bdcd2ee9e31bc03cba0d16c43d428 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 5 21:29:01 2019 +0200 patch 8.1.1988: :startinsert! does not work the same way as "A" Problem: :startinsert! does not work the same way as "A". Solution: Use the same code to move the cursor. (closes https://github.com/vim/vim/issues/4896)
author Bram Moolenaar <Bram@vim.org>
date Thu, 05 Sep 2019 21:30:03 +0200
parents ce993ba17adb
children 8a2fb21c23c0
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
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
3 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
4 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
5 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
6 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
7
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
8 call assert_equal(1, assert_false(123))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
9 call assert_match("Expected False but got 123", v:errors[0])
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
10 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
11
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
12 call assert_equal(1, 123->assert_false())
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
13 call assert_match("Expected False but got 123", 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
14 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 endfunc
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
17 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
18 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
19 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
20 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
21 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
22
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
23 call assert_equal(1, assert_true(0))
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
24 call assert_match("Expected True but got 0", v:errors[0])
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
25 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
26
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
27 call assert_equal(1, 0->assert_true())
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
28 call assert_match("Expected True but got 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
29 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endfunc
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
7279
b5e9810b389d commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents: 7277
diff changeset
32 func Test_assert_equal()
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 let s = 'foo'
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
34 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
35 let n = 4
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
36 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
37 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
38 call assert_equal(0, 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
39
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
40 let s = 'foo'
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(1, assert_equal('bar', s))
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
42 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
43 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
44
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
45 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
46 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
47 call remove(v:errors, 0)
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
48 endfunc
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
49
13298
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
50 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
51 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
52 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
53 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
54
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
55 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
56 call writefile(goodtext, 'Xone')
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
57 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
58 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
59 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
60
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
61 call writefile(goodtext, 'Xtwo')
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
62 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
63
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
64 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
65 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
66 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
67 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
68
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
69 call writefile(goodtext, 'Xone')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
70 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
71 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
72 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
73 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
74
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
75 call writefile(['1234X89'], 'Xone')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
76 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
77 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
78 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
79 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
80
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
81 call delete('Xone')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
82 call delete('Xtwo')
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
83 endfunc
a88c5e12b860 patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents: 13272
diff changeset
84
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
85 func Test_assert_notequal()
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
86 let n = 4
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
87 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
88 let s = 'foo'
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
89 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
90
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
91 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
92 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
93 call remove(v:errors, 0)
7277
6600871bb38c commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 endfunc
7412
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
95
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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104
7675
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
105 func Test_assert_exception()
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
106 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
107 nocommand
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
108 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
109 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
110 endtry
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
111
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
112 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
113 nocommand
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
114 catch
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
115 try
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
116 " 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
117 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
118 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
119 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
120 endtry
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
121 endtry
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
122 endfunc
eb9cc96138a3 commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents: 7412
diff changeset
123
7852
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
124 func Test_wrong_error_type()
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
125 let save_verrors = v:errors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
126 let v:['errors'] = {'foo': 3}
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
127 call assert_equal('yes', 'no')
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
128 let verrors = v:errors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
129 let v:errors = save_verrors
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
130 call assert_equal(type([]), type(verrors))
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
131 endfunc
8818755d8326 commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents: 7675
diff changeset
132
8550
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
133 func Test_compare_fail()
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
134 let s:v = {}
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
135 let s:x = {"a": s:v}
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
136 let s:v["b"] = s:x
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
137 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
138 try
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
139 call assert_equal(s:w, '')
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
140 catch
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
141 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
142 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
143 call remove(v:errors, 0)
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
144 endtry
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
145 endfunc
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
146
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
147 func Test_match()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
148 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
149
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
150 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
151 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
152 call remove(v:errors, 0)
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
153
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
154 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
155 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
156 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
157
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
158 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
159 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
160 call remove(v:errors, 0)
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
161 endfunc
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
162
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
163 func Test_notmatch()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
164 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
165 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
166
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
167 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
168 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
169 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
170
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
171 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
172 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
173 call remove(v:errors, 0)
8831
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
174 endfunc
6f41d68aa68e commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233
Christian Brabandt <cb@256bit.org>
parents: 8749
diff changeset
175
8554
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
176 func Test_assert_fail_fails()
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
177 call assert_equal(1, assert_fails('xxx', {}))
8749
65a5a18d3acf commit https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Christian Brabandt <cb@256bit.org>
parents: 8554
diff changeset
178 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
179 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
180
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
181 call assert_equal(1, assert_fails('xxx', {}, 'stupid'))
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
182 call assert_match("stupid: Expected {} but got 'E731:", 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
183 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
184
0c845463a0db patch 8.1.0460: assert_fails() does not take a message argument
Bram Moolenaar <Bram@vim.org>
parents: 14053
diff changeset
185 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
186 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
187 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
188
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
189 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
190 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
191 call remove(v:errors, 0)
8554
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
192 endfunc
7d3548ae729d commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents: 8550
diff changeset
193
17322
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
194 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
195 try
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
196 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
197 endtry
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
198 endfunc
ccd21c8f916b patch 8.1.1660: assert_fails() does not fail inside try/catch
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
199
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
200 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
201 new
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
202 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
203
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
204 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
205 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
206 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
207
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17322
diff changeset
208 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
209 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
210 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
211 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
212
13272
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
213 bwipe
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
214 endfunc
abaebba89fd4 patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
215
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
216 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
217 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
218 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
219 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
220 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
221
13796
87012d2b17b5 patch 8.0.1770: assert functions don't return anything
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
222 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
223 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
224 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
225 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
226 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
227 call remove(v:errors, 0)
10462
0d345265b1e2 commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
228
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 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
230 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
231 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
232 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
233 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
234
10462
0d345265b1e2 commit https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
235 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
236
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
237 if has('float')
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
238 call assert_equal(0, assert_inrange(7.0, 7, 7))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
239 call assert_equal(0, assert_inrange(7, 7.0, 7))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
240 call assert_equal(0, assert_inrange(7, 7, 7.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
241 call assert_equal(0, assert_inrange(5, 7, 5.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
242 call assert_equal(0, assert_inrange(5, 7, 6.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
243 call assert_equal(0, assert_inrange(5, 7, 7.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
244
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
245 call assert_equal(1, assert_inrange(5, 7, 4.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
246 call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0])
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
247 call remove(v:errors, 0)
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
248 call assert_equal(1, assert_inrange(5, 7, 8.0))
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
249 call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
250 call remove(v:errors, 0)
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15623
diff changeset
251 endif
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 8831
diff changeset
252 endfunc
8550
56d0eb96c25a commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents: 7951
diff changeset
253
10728
8ba322dad776 patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents: 10593
diff changeset
254 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
255 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
256 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
257 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
258 endfunc
8ba322dad776 patch 8.0.0254: error message of assert functions is sometimes incomplete
Christian Brabandt <cb@256bit.org>
parents: 10593
diff changeset
259
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
260 func Test_override()
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
261 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
262 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
263 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
264 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
265 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
266 endfunc
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 10728
diff changeset
267
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
268 func Test_mouse_position()
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
269 let save_mouse = &mouse
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
270 set mouse=a
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
271 new
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
272 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
273 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
274 call test_setmouse(1, 5)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
275 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
276 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
277 call test_setmouse(2, 20)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
278 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
279 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
280 call test_setmouse(5, 1)
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
281 call feedkeys("\<LeftMouse>", "xt")
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
282 call assert_equal([0, 2, 1, 0], getpos('.'))
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
283 bwipe!
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
284 let &mouse = save_mouse
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
285 endfunc
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
286
7412
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
287 func Test_user_is_happy()
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
288 smile
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
289 sleep 300m
bc5de65e499a commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents: 7279
diff changeset
290 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
291
d6866c54a311 patch 8.1.0044: if a test function exists Vim this may go unnoticed
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
292 " 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
293 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
294 " 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
295 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
296 endfunc