Mercurial > vim
annotate src/testdir/test_timers.vim @ 31764:6969fac11aaa v9.0.1214
patch 9.0.1214: file left behind after running tests
Commit: https://github.com/vim/vim/commit/541c87c808df91b55e51fedc4987152a3edfe80d
Author: Dominique Pelle <dominique.pelle@gmail.com>
Date: Tue Jan 17 21:20:44 2023 +0000
patch 9.0.1214: file left behind after running tests
Problem: File left behind after running tests.
Solution: Delete the file. (Dominique Pell?, closes https://github.com/vim/vim/issues/11839)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 17 Jan 2023 22:30:04 +0100 |
parents | c8ebe35b2475 |
children | dbec60b8c253 |
rev | line source |
---|---|
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for timers |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
3 source check.vim |
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
4 CheckFeature timers |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
20709
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
6 source screendump.vim |
12568
440d934bd616
patch 8.0.1162: shared script for tests cannot be included twice
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7 source shared.vim |
17164
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
17159
diff
changeset
|
8 source term_util.vim |
12351
4e61b77cd96f
patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12347
diff
changeset
|
9 |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 func MyHandler(timer) |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
11 let g:val += 1 |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
9153
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
14 func MyHandlerWithLists(lists, timer) |
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
15 let x = string(a:lists) |
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
16 endfunc |
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
17 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
18 func Test_timer_oneshot() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
19 let g:test_is_flaky = 1 |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
20 let g:val = 0 |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 let timer = timer_start(50, 'MyHandler') |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
22 let slept = WaitFor('g:val == 1') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
23 call assert_equal(1, g:val) |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
24 if has('mac') |
18964
8295f4061dc2
patch 8.2.0043: timers test is still flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18920
diff
changeset
|
25 " Mac on Travis can be very slow. |
8295f4061dc2
patch 8.2.0043: timers test is still flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18920
diff
changeset
|
26 let limit = 180 |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
27 else |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
28 let limit = 100 |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
29 endif |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
30 if has('reltime') |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
31 call assert_inrange(49, limit, slept) |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
32 else |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
33 call assert_inrange(20, limit, slept) |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
34 endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 endfunc |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
37 func Test_timer_repeat_three() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
38 let g:test_is_flaky = 1 |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
39 let g:val = 0 |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 let timer = timer_start(50, 'MyHandler', {'repeat': 3}) |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
41 let slept = WaitFor('g:val == 3') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
42 call assert_equal(3, g:val) |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
43 if has('reltime') |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
44 if has('mac') |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
45 " Mac on Travis can be slow. |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
46 call assert_inrange(149, 400, slept) |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
47 else |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
48 call assert_inrange(149, 250, slept) |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
49 endif |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
50 else |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
51 call assert_inrange(80, 200, slept) |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
52 endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 endfunc |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
55 func Test_timer_repeat_many() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
56 let g:test_is_flaky = 1 |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
57 let g:val = 0 |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 let timer = timer_start(50, 'MyHandler', {'repeat': -1}) |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 sleep 200m |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 call timer_stop(timer) |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
61 " Mac on Travis can be slow. |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
62 if has('mac') |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
63 call assert_inrange(1, 5, g:val) |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
64 else |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
65 call assert_inrange(2, 5, g:val) |
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
66 endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 endfunc |
8734
986f7c00d43d
commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
68 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
69 func Test_timer_with_partial_callback() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
70 let g:test_is_flaky = 1 |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
71 let g:val = 0 |
10178
776d0aef1d80
commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents:
10122
diff
changeset
|
72 let meow = {'one': 1} |
776d0aef1d80
commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents:
10122
diff
changeset
|
73 function meow.bite(...) |
776d0aef1d80
commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents:
10122
diff
changeset
|
74 let g:val += self.one |
8734
986f7c00d43d
commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
75 endfunction |
986f7c00d43d
commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
76 |
10178
776d0aef1d80
commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents:
10122
diff
changeset
|
77 call timer_start(50, meow.bite) |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
78 let slept = WaitFor('g:val == 1') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
79 call assert_equal(1, g:val) |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
80 if has('reltime') |
18975
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
81 " Mac on Travis can be slow. |
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
82 if has('mac') |
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
83 call assert_inrange(49, 180, slept) |
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
84 else |
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
85 call assert_inrange(49, 130, slept) |
8696f0ebeb43
patch 8.2.0048: another timers test is flaky on Travis for Mac
Bram Moolenaar <Bram@vim.org>
parents:
18964
diff
changeset
|
86 endif |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
87 else |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
88 call assert_inrange(20, 100, slept) |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
89 endif |
8734
986f7c00d43d
commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
90 endfunc |
9153
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
91 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
92 func Test_timer_retain_partial() |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
93 call timer_start(50, function('MyHandlerWithLists', [['a']])) |
9153
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
94 call test_garbagecollect_now() |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
95 sleep 100m |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
96 endfunc |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
97 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
98 func Test_timer_info() |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
99 let id = timer_start(1000, 'MyHandler') |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18031
diff
changeset
|
100 let info = id->timer_info() |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
101 call assert_equal(id, info[0]['id']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
102 call assert_equal(1000, info[0]['time']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
103 call assert_true(info[0]['remaining'] > 500) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
104 call assert_true(info[0]['remaining'] <= 1000) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
105 call assert_equal(1, info[0]['repeat']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
106 call assert_equal("function('MyHandler')", string(info[0]['callback'])) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
107 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
108 let found = 0 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
109 for info in timer_info() |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
110 if info['id'] == id |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
111 let found += 1 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
112 endif |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
113 endfor |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
114 call assert_equal(1, found) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
115 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
116 call timer_stop(id) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
117 call assert_equal([], timer_info(id)) |
19289
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
118 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
119 call assert_fails('call timer_info("abc")', 'E1210:') |
26476
7426c2657710
patch 8.2.3768: timer_info() has the wrong repeat value in a timer callback
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
120 |
7426c2657710
patch 8.2.3768: timer_info() has the wrong repeat value in a timer callback
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
121 " check repeat count inside the callback |
7426c2657710
patch 8.2.3768: timer_info() has the wrong repeat value in a timer callback
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
122 let g:timer_repeat = [] |
7426c2657710
patch 8.2.3768: timer_info() has the wrong repeat value in a timer callback
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
123 let tid = timer_start(10, {tid -> execute("call add(g:timer_repeat, timer_info(tid)[0].repeat)")}, #{repeat: 3}) |
26484
d945799b4604
patch 8.2.3772: timer info test fails on slow machine
Bram Moolenaar <Bram@vim.org>
parents:
26476
diff
changeset
|
124 call WaitForAssert({-> assert_equal([2, 1, 0], g:timer_repeat)}) |
26476
7426c2657710
patch 8.2.3768: timer_info() has the wrong repeat value in a timer callback
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
125 unlet g:timer_repeat |
9153
c2fe86f2bda1
commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents:
8734
diff
changeset
|
126 endfunc |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
127 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
128 func Test_timer_stopall() |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
129 let id1 = timer_start(1000, 'MyHandler') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
130 let id2 = timer_start(2000, 'MyHandler') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
131 let info = timer_info() |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
132 " count one for the TestTimeout() timer |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
133 call assert_equal(3, len(info)) |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
134 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
135 call timer_stopall() |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
136 let info = timer_info() |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
137 call assert_equal(0, len(info)) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
138 endfunc |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
139 |
30695
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
140 def Test_timer_stopall_with_popup() |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
141 # Create a popup that times out after ten seconds. |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
142 # Another timer will fire in half a second and close it early after stopping |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
143 # all timers. |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
144 var pop = popup_create('Popup', {time: 10000}) |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
145 var tmr = timer_start(500, (_) => { |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
146 timer_stopall() |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
147 popup_clear() |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
148 }) |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
149 sleep 1 |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
150 assert_equal([], timer_info(tmr)) |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
151 assert_equal([], popup_list()) |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
152 enddef |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30485
diff
changeset
|
153 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
154 func Test_timer_paused() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
155 let g:test_is_flaky = 1 |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
156 let g:val = 0 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
157 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
158 let id = timer_start(50, 'MyHandler') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
159 let info = timer_info(id) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
160 call assert_equal(0, info[0]['paused']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
161 |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18031
diff
changeset
|
162 eval id->timer_pause(1) |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
163 let info = timer_info(id) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
164 call assert_equal(1, info[0]['paused']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
165 sleep 100m |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
166 call assert_equal(0, g:val) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
167 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
168 call timer_pause(id, 0) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
169 let info = timer_info(id) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
170 call assert_equal(0, info[0]['paused']) |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
171 |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
172 let slept = WaitFor('g:val == 1') |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
173 call assert_equal(1, g:val) |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
174 if has('reltime') |
13098
318577da90b1
patch 8.0.1424: the timer_pause test is flaky on Travis
Christian Brabandt <cb@256bit.org>
parents:
12568
diff
changeset
|
175 if has('mac') |
318577da90b1
patch 8.0.1424: the timer_pause test is flaky on Travis
Christian Brabandt <cb@256bit.org>
parents:
12568
diff
changeset
|
176 " The travis Mac machines appear to be very busy. |
18920
a76fdc6560c3
patch 8.2.0021: timer test fails too often on Travis with MacOS
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
177 call assert_inrange(0, 90, slept) |
13098
318577da90b1
patch 8.0.1424: the timer_pause test is flaky on Travis
Christian Brabandt <cb@256bit.org>
parents:
12568
diff
changeset
|
178 else |
318577da90b1
patch 8.0.1424: the timer_pause test is flaky on Travis
Christian Brabandt <cb@256bit.org>
parents:
12568
diff
changeset
|
179 call assert_inrange(0, 30, slept) |
318577da90b1
patch 8.0.1424: the timer_pause test is flaky on Travis
Christian Brabandt <cb@256bit.org>
parents:
12568
diff
changeset
|
180 endif |
9933
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
181 else |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
182 call assert_inrange(0, 10, slept) |
7f38e72a9d65
commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents:
9909
diff
changeset
|
183 endif |
19289
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
184 |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
185 call assert_fails('call timer_pause("abc", 1)', 'E39:') |
9810
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
186 endfunc |
6a28d0c6f929
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents:
9153
diff
changeset
|
187 |
10066
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
188 func StopMyself(timer) |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
189 let g:called += 1 |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
190 if g:called == 2 |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
191 call timer_stop(a:timer) |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
192 endif |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
193 endfunc |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
194 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
195 func Test_timer_delete_myself() |
10066
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
196 let g:called = 0 |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
197 let t = timer_start(10, 'StopMyself', {'repeat': -1}) |
13808
16a062cf08c2
patch 8.0.1776: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13164
diff
changeset
|
198 call WaitForAssert({-> assert_equal(2, g:called)}) |
10066
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
199 call assert_equal(2, g:called) |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
200 call assert_equal([], timer_info(t)) |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
201 endfunc |
dc1610dc910f
commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents:
10017
diff
changeset
|
202 |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
203 func StopTimer1(timer) |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18031
diff
changeset
|
204 let g:timer2 = 10->timer_start('StopTimer2') |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
205 " avoid maxfuncdepth error |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
206 call timer_pause(g:timer1, 1) |
17734
c92899aa761a
patch 8.1.1864: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17724
diff
changeset
|
207 sleep 20m |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
208 endfunc |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
209 |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
210 func StopTimer2(timer) |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
211 call timer_stop(g:timer1) |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
212 endfunc |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
213 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
214 func Test_timer_stop_in_callback() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
215 let g:test_is_flaky = 1 |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
216 call assert_equal(1, len(timer_info())) |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
217 let g:timer1 = timer_start(10, 'StopTimer1') |
17740
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
218 let slept = 0 |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
219 for i in range(10) |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
220 if len(timer_info()) == 1 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
221 break |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
222 endif |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
223 sleep 10m |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
224 let slept += 10 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
225 endfor |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
226 if slept == 100 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
227 call assert_equal(1, len(timer_info())) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
228 else |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
229 " This should take only 30 msec, but on Mac it's often longer |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
230 call assert_inrange(0, 50, slept) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
231 endif |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
232 endfunc |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
233 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
234 func StopTimerAll(timer) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
235 call timer_stopall() |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
236 endfunc |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
237 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
238 func Test_timer_stop_all_in_callback() |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
239 let g:test_is_flaky = 1 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
240 " One timer is for TestTimeout() |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
241 call assert_equal(1, len(timer_info())) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
242 call timer_start(10, 'StopTimerAll') |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
243 call assert_equal(2, len(timer_info())) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
244 let slept = 0 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
245 for i in range(10) |
17740
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
246 if len(timer_info()) == 0 |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
247 break |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
248 endif |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
249 sleep 10m |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
250 let slept += 10 |
01205ef5646d
patch 8.1.1867: still a timer test that is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
17734
diff
changeset
|
251 endfor |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
252 if slept == 100 |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
253 call assert_equal(0, len(timer_info())) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
254 else |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
255 call assert_inrange(0, 30, slept) |
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
256 endif |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
257 endfunc |
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
258 |
11575
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
259 func FeedkeysCb(timer) |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
260 call feedkeys("hello\<CR>", 'nt') |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
261 endfunc |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
262 |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
263 func InputCb(timer) |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
264 call timer_start(10, 'FeedkeysCb') |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
265 let g:val = input('?') |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
266 call Resume() |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
267 endfunc |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
268 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
269 func Test_timer_input_in_timer() |
11575
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
270 let g:val = '' |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
271 call timer_start(10, 'InputCb') |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
272 call Standby(1000) |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
273 call assert_equal('hello', g:val) |
0ec755ff1fe2
patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents:
10178
diff
changeset
|
274 endfunc |
10122
3db463d4df25
commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents:
10066
diff
changeset
|
275 |
11639
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
276 func FuncWithError(timer) |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
277 let g:call_count += 1 |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
278 if g:call_count == 4 |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
279 return |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
280 endif |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
281 doesnotexist |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
282 endfunc |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
283 |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
284 func Test_timer_errors() |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
285 let g:call_count = 0 |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
286 let timer = timer_start(10, 'FuncWithError', {'repeat': -1}) |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
287 " Timer will be stopped after failing 3 out of 3 times. |
13808
16a062cf08c2
patch 8.0.1776: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13164
diff
changeset
|
288 call WaitForAssert({-> assert_equal(3, g:call_count)}) |
11639
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
289 sleep 50m |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
290 call assert_equal(3, g:call_count) |
19289
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
291 |
29994
86eb4aba16c3
patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents:
29434
diff
changeset
|
292 call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E1206:') |
19289
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
293 call assert_fails('call timer_start(100, [])', 'E921:') |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
294 call assert_fails('call timer_stop("abc")', 'E1210:') |
11639
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
295 endfunc |
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
296 |
12375
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
297 func FuncWithCaughtError(timer) |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
298 let g:call_count += 1 |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
299 try |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
300 doesnotexist |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
301 catch |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
302 " nop |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
303 endtry |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
304 endfunc |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
305 |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
306 func Test_timer_catch_error() |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
307 let g:call_count = 0 |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
308 let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4}) |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
309 " Timer will not be stopped. |
13808
16a062cf08c2
patch 8.0.1776: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13164
diff
changeset
|
310 call WaitForAssert({-> assert_equal(4, g:call_count)}) |
12375
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
311 sleep 50m |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
312 call assert_equal(4, g:call_count) |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
313 endfunc |
ab0d827151a1
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Christian Brabandt <cb@256bit.org>
parents:
12351
diff
changeset
|
314 |
12337
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
315 func FeedAndPeek(timer) |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
316 call test_feedinput('a') |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
317 call getchar(1) |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
318 endfunc |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
319 |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
320 func Interrupt(timer) |
18031
8a2fb21c23c0
patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17740
diff
changeset
|
321 eval "\<C-C>"->test_feedinput() |
12337
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
322 endfunc |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
323 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
324 func Test_timer_peek_and_get_char() |
29353
0c403f53b372
patch 9.0.0019: timers test not run where possible
Bram Moolenaar <Bram@vim.org>
parents:
27275
diff
changeset
|
325 if !has('unix') && !has('gui_running') |
0c403f53b372
patch 9.0.0019: timers test not run where possible
Bram Moolenaar <Bram@vim.org>
parents:
27275
diff
changeset
|
326 throw 'Skipped: cannot feed low-level input' |
0c403f53b372
patch 9.0.0019: timers test not run where possible
Bram Moolenaar <Bram@vim.org>
parents:
27275
diff
changeset
|
327 endif |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17249
diff
changeset
|
328 |
12337
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
329 call timer_start(0, 'FeedAndPeek') |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
330 let intr = timer_start(100, 'Interrupt') |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
331 let c = getchar() |
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
332 call assert_equal(char2nr('a'), c) |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18031
diff
changeset
|
333 eval intr->timer_stop() |
12337
040a892d0eed
patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents:
11639
diff
changeset
|
334 endfunc |
11639
71d7b5ed08a0
patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents:
11575
diff
changeset
|
335 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
336 func Test_timer_getchar_zero() |
15687
cb501b3c9fb5
patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
15673
diff
changeset
|
337 if has('win32') && !has('gui_running') |
29353
0c403f53b372
patch 9.0.0019: timers test not run where possible
Bram Moolenaar <Bram@vim.org>
parents:
27275
diff
changeset
|
338 throw 'Skipped: cannot feed low-level input' |
15669
d2ec272ae777
patch 8.1.0842: getchar_zero test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
15665
diff
changeset
|
339 endif |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
18975
diff
changeset
|
340 CheckFunction reltimefloat |
15669
d2ec272ae777
patch 8.1.0842: getchar_zero test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
15665
diff
changeset
|
341 |
15673
2973d8252740
patch 8.1.0844: when timer fails test will hang forever
Bram Moolenaar <Bram@vim.org>
parents:
15669
diff
changeset
|
342 " Measure the elapsed time to avoid a hang when it fails. |
2973d8252740
patch 8.1.0844: when timer fails test will hang forever
Bram Moolenaar <Bram@vim.org>
parents:
15669
diff
changeset
|
343 let start = reltime() |
15687
cb501b3c9fb5
patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
15673
diff
changeset
|
344 let id = timer_start(20, {-> feedkeys('x', 'L')}) |
15665
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
345 let c = 0 |
15673
2973d8252740
patch 8.1.0844: when timer fails test will hang forever
Bram Moolenaar <Bram@vim.org>
parents:
15669
diff
changeset
|
346 while c == 0 && reltimefloat(reltime(start)) < 0.2 |
15665
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
347 let c = getchar(0) |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
348 sleep 10m |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
349 endwhile |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
350 call assert_equal('x', nr2char(c)) |
15669
d2ec272ae777
patch 8.1.0842: getchar_zero test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
15665
diff
changeset
|
351 call timer_stop(id) |
15665
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
352 endfunc |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
13892
diff
changeset
|
353 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
354 func Test_timer_ex_mode() |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
355 " Function with an empty line. |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
356 func Foo(...) |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
357 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
358 endfunc |
15669
d2ec272ae777
patch 8.1.0842: getchar_zero test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
15665
diff
changeset
|
359 let timer = timer_start(40, function('g:Foo'), {'repeat':-1}) |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
360 " This used to throw error E749. |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
361 exe "normal Qsleep 100m\rvi\r" |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
362 call timer_stop(timer) |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
363 endfunc |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12375
diff
changeset
|
364 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
365 func Test_timer_restore_count() |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
366 CheckRunVimInTerminal |
13892
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
367 " Check that v:count is saved and restored, not changed by a timer. |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
368 call writefile([ |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
369 \ 'nnoremap <expr><silent> L v:count ? v:count . "l" : "l"', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
370 \ 'func Doit(id)', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
371 \ ' normal 3j', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
372 \ 'endfunc', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
373 \ 'call timer_start(100, "Doit")', |
30865
c8ebe35b2475
patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
374 \ ], 'Xtrcscript', 'D') |
13892
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
375 call writefile([ |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
376 \ '1-1234', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
377 \ '2-1234', |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
378 \ '3-1234', |
30865
c8ebe35b2475
patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
379 \ ], 'Xtrctext', 'D') |
13892
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
380 let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {}) |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
381 |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
382 " Wait for the timer to move the cursor to the third line. |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
383 call WaitForAssert({-> assert_equal(3, term_getcursor(buf)[0])}) |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
384 call assert_equal(1, term_getcursor(buf)[1]) |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
385 " Now check that v:count has not been set to 3 |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
386 call term_sendkeys(buf, 'L') |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
387 call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])}) |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
388 |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
389 call StopVimInTerminal(buf) |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
390 endfunc |
eadecbe4e390
patch 8.0.1817: a timer may change v:count unexpectedly
Christian Brabandt <cb@256bit.org>
parents:
13808
diff
changeset
|
391 |
17159
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
392 " Test that the garbage collector isn't triggered if a timer callback invokes |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
393 " vgetc(). |
29434
5da38c4ffe92
patch 9.0.0059: test file has wrong name
Bram Moolenaar <Bram@vim.org>
parents:
29353
diff
changeset
|
394 func Test_nocatch_timer_garbage_collect() |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
395 " FIXME: why does this fail only on MacOS M1? |
30477
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
396 try |
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
397 CheckNotMacM1 |
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
398 catch /Skipped/ |
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
399 let g:skipped_reason = v:exception |
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
400 return |
5e99ae766688
patch 9.0.0574: timer garbage collect test hangs on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30457
diff
changeset
|
401 endtry |
30457
7ab65e398be7
patch 9.0.0564: a few tests keep failing on MacOS M1
Bram Moolenaar <Bram@vim.org>
parents:
30447
diff
changeset
|
402 |
17159
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
403 " 'uptimetime. must be bigger than the timer timeout |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
404 set ut=200 |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
405 call test_garbagecollect_soon() |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
406 call test_override('no_wait_return', 0) |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
407 func CauseAnError(id) |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
408 " This will show an error and wait for Enter. |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
409 let a = {'foo', 'bar'} |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
410 endfunc |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
411 func FeedChar(id) |
30447
db70368fd2b9
patch 9.0.0559: timer test may get stuck at hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
412 call feedkeys(":\<CR>", 't') |
17159
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
413 endfunc |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
414 call timer_start(300, 'FeedChar') |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
415 call timer_start(100, 'CauseAnError') |
30447
db70368fd2b9
patch 9.0.0559: timer test may get stuck at hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
416 let x = getchar() " wait for error in timer |
db70368fd2b9
patch 9.0.0559: timer test may get stuck at hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
417 let x = getchar(0) " read any remaining chars |
db70368fd2b9
patch 9.0.0559: timer test may get stuck at hit-enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
418 let x = getchar(0) |
17159
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
419 |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
420 set ut& |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
421 call test_override('no_wait_return', 1) |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
422 delfunc CauseAnError |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
423 delfunc FeedChar |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
424 endfunc |
3fd0765f454f
patch 8.1.1579: dict and list could be GC'ed while displaying error
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
425 |
17716
50b3b9c13ab8
patch 8.1.1855: another failing timer test
Bram Moolenaar <Bram@vim.org>
parents:
17710
diff
changeset
|
426 func Test_timer_error_in_timer_callback() |
17249
3e2e998ce0db
patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
17239
diff
changeset
|
427 if !has('terminal') || (has('win32') && has('gui_running')) |
17184
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
428 throw 'Skipped: cannot run Vim in a terminal window' |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
429 endif |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
430 |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
431 let lines =<< trim [CODE] |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
432 func Func(timer) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
433 " fail to create list |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
434 let x = [ |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
435 endfunc |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
436 set updatetime=50 |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
437 call timer_start(1, 'Func') |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
438 [CODE] |
30865
c8ebe35b2475
patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
439 call writefile(lines, 'Xtest.vim', 'D') |
17184
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
440 |
17249
3e2e998ce0db
patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
17239
diff
changeset
|
441 let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8}) |
17184
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
442 let job = term_getjob(buf) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
443 call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))}) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
444 |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
445 " GC must not run during timer callback, which can make Vim crash. |
19954
c087099e9163
patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents:
19609
diff
changeset
|
446 call TermWait(buf, 50) |
17184
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
447 call term_sendkeys(buf, "\<CR>") |
19954
c087099e9163
patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents:
19609
diff
changeset
|
448 call TermWait(buf, 50) |
17184
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
449 call assert_equal('run', job_status(job)) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
450 |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
451 call term_sendkeys(buf, ":qall!\<CR>") |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
452 call WaitFor({-> job_status(job) ==# 'dead'}) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
453 if has('unix') |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
454 call assert_equal('', job_info(job).termsig) |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
455 endif |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
456 |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
457 exe buf .. 'bwipe!' |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
458 endfunc |
a5c3d374e1d3
patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
459 |
19289
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
460 " Test for garbage collection when a timer is still running |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
461 func Test_timer_garbage_collect() |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
462 let timer = timer_start(1000, function('MyHandler'), {'repeat' : 10}) |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
463 call test_garbagecollect_now() |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
464 let l = timer_info(timer) |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
465 call assert_equal(function('MyHandler'), l[0].callback) |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
466 call timer_stop(timer) |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
467 endfunc |
2f0f308c069c
patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
468 |
19609
fe827d6267c2
patch 8.2.0361: internal error when using "0" for a callback
Bram Moolenaar <Bram@vim.org>
parents:
19289
diff
changeset
|
469 func Test_timer_invalid_callback() |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
20709
diff
changeset
|
470 call assert_fails('call timer_start(0, "0")', 'E921:') |
19609
fe827d6267c2
patch 8.2.0361: internal error when using "0" for a callback
Bram Moolenaar <Bram@vim.org>
parents:
19289
diff
changeset
|
471 endfunc |
fe827d6267c2
patch 8.2.0361: internal error when using "0" for a callback
Bram Moolenaar <Bram@vim.org>
parents:
19289
diff
changeset
|
472 |
20709
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
473 func Test_timer_changing_function_list() |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
474 CheckRunVimInTerminal |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
475 |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
476 " Create a large number of functions. Should get the "more" prompt. |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
477 " The typing "G" triggers the timer, which changes the function table. |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
478 let lines =<< trim END |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
479 for func in map(range(1,99), "'Func' .. v:val") |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
480 exe "func " .. func .. "()" |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
481 endfunc |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
482 endfor |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
483 au CmdlineLeave : call timer_start(0, {-> 0}) |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
484 END |
30865
c8ebe35b2475
patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
485 call writefile(lines, 'XTest_timerchange', 'D') |
20709
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
486 let buf = RunVimInTerminal('-S XTest_timerchange', #{rows: 10}) |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
487 call term_sendkeys(buf, ":fu\<CR>") |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
488 call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 10))}) |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
489 call term_sendkeys(buf, "G") |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
20709
diff
changeset
|
490 call WaitForAssert({-> assert_match('E454:', term_getline(buf, 9))}) |
20709
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
491 call term_sendkeys(buf, "\<Esc>") |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
492 |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
493 call StopVimInTerminal(buf) |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
494 endfunc |
a2262c80a4e0
patch 8.2.0908: crash when changing the function table while listing it
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
495 |
24521
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
496 func Test_timer_outputting_message() |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
497 CheckRunVimInTerminal |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
498 |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
499 let lines =<< trim END |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
500 vim9script |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
501 setline(1, 'some text') |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
502 set showcmd ut=2000 cmdheight=1 |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
503 timer_start(0, (_) => { |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
504 echon repeat('x', &columns - 11) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
505 }) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
506 END |
30865
c8ebe35b2475
patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
507 call writefile(lines, 'XTest_timermessage', 'D') |
24521
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
508 let buf = RunVimInTerminal('-S XTest_timermessage', #{rows: 6}) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
509 call term_sendkeys(buf, "l") |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
510 call term_wait(buf) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
511 " should not get a hit-enter prompt |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
512 call WaitForAssert({-> assert_match('xxxxxxxxxxx', term_getline(buf, 6))}) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
513 |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
514 call StopVimInTerminal(buf) |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
515 endfunc |
3efc5cb6a404
patch 8.2.2800: after a timer displays text a hit-enter prompt is given
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
516 |
27275
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
517 func Test_timer_using_win_execute_undo_sync() |
30485
57890fe84655
patch 9.0.0578: one timer test fails on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30477
diff
changeset
|
518 " FIXME: why does this fail only on MacOS M1? |
57890fe84655
patch 9.0.0578: one timer test fails on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30477
diff
changeset
|
519 CheckNotMacM1 |
57890fe84655
patch 9.0.0578: one timer test fails on Mac M1
Bram Moolenaar <Bram@vim.org>
parents:
30477
diff
changeset
|
520 |
27275
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
521 let bufnr1 = bufnr() |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
522 new |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
523 let g:bufnr2 = bufnr() |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
524 let g:winid = win_getid() |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
525 exe "buffer " .. bufnr1 |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
526 wincmd w |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
527 call setline(1, ['test']) |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
528 autocmd InsertEnter * call timer_start(100, { -> win_execute(g:winid, 'buffer ' .. g:bufnr2) }) |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
529 call timer_start(200, { -> feedkeys("\<CR>bbbb\<Esc>") }) |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
530 call feedkeys("Oaaaa", 'x!t') |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
531 " will hang here until the second timer fires |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
532 call assert_equal(['aaaa', 'bbbb', 'test'], getline(1, '$')) |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
533 undo |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
534 call assert_equal(['test'], getline(1, '$')) |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
535 |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
536 bwipe! |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
537 bwipe! |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
538 unlet g:winid |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
539 unlet g:bufnr2 |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
540 au! InsertEnter |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
541 endfunc |
841145bb9885
patch 8.2.4166: undo synced when switching buffer in another window
Bram Moolenaar <Bram@vim.org>
parents:
26484
diff
changeset
|
542 |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
24521
diff
changeset
|
543 |
9909
3ee84d270ea7
commit https://github.com/vim/vim/commit/9e4d8215d386100ab660d7d11e6620fd148b605e
Christian Brabandt <cb@256bit.org>
parents:
9822
diff
changeset
|
544 " vim: shiftwidth=2 sts=2 expandtab |