annotate src/testdir/test_timers.vim @ 12351:4e61b77cd96f v8.0.1055

patch 8.0.1055: bufline test hangs on MS-Windows commit https://github.com/vim/vim/commit/11aa62f8f949bb590b4d7792a334885fba5e4137 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 4 22:56:01 2017 +0200 patch 8.0.1055: bufline test hangs on MS-Windows Problem: Bufline test hangs on MS-Windows. Solution: Avoid message for writing file. Source shared.vim when running test individually.
author Christian Brabandt <cb@256bit.org>
date Mon, 04 Sep 2017 23:00:05 +0200
parents 61a9642297cc
children ab0d827151a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('timers')
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
7 if !exists('*WaitFor')
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
8 source shared.vim
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
9 endif
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
10
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 func MyHandler(timer)
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
12 let g:val += 1
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 endfunc
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
9153
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
15 func MyHandlerWithLists(lists, timer)
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
16 let x = string(a:lists)
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
17 endfunc
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
18
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 func Test_oneshot()
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)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
24 if has('reltime')
10017
f132b956e9b5 commit https://github.com/vim/vim/commit/0426bae2abede764d0dd366a28663d1c6e6ab0fe
Christian Brabandt <cb@256bit.org>
parents: 9937
diff changeset
25 call assert_inrange(49, 100, slept)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
26 else
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
27 call assert_inrange(20, 100, slept)
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
28 endif
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunc
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 func Test_repeat_three()
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
32 let g:val = 0
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 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
34 let slept = WaitFor('g:val == 3')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
35 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
36 if has('reltime')
10017
f132b956e9b5 commit https://github.com/vim/vim/commit/0426bae2abede764d0dd366a28663d1c6e6ab0fe
Christian Brabandt <cb@256bit.org>
parents: 9937
diff changeset
37 call assert_inrange(149, 250, slept)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
38 else
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
39 call assert_inrange(80, 200, slept)
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
40 endif
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 endfunc
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 func Test_repeat_many()
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
44 let g:val = 0
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 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
46 sleep 200m
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call timer_stop(timer)
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
48 call assert_inrange(2, 4, g:val)
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfunc
8734
986f7c00d43d commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
50
986f7c00d43d commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
51 func Test_with_partial_callback()
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
52 let g:val = 0
10178
776d0aef1d80 commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents: 10122
diff changeset
53 let meow = {'one': 1}
776d0aef1d80 commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents: 10122
diff changeset
54 function meow.bite(...)
776d0aef1d80 commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents: 10122
diff changeset
55 let g:val += self.one
8734
986f7c00d43d commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
56 endfunction
986f7c00d43d commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
57
10178
776d0aef1d80 commit https://github.com/vim/vim/commit/26fe0d56912e42c2b16a61b2480e19ba569aee98
Christian Brabandt <cb@256bit.org>
parents: 10122
diff changeset
58 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
59 let slept = WaitFor('g:val == 1')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
60 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
61 if has('reltime')
10017
f132b956e9b5 commit https://github.com/vim/vim/commit/0426bae2abede764d0dd366a28663d1c6e6ab0fe
Christian Brabandt <cb@256bit.org>
parents: 9937
diff changeset
62 call assert_inrange(49, 130, slept)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
63 else
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
64 call assert_inrange(20, 100, slept)
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
65 endif
8734
986f7c00d43d commit https://github.com/vim/vim/commit/92e35efaf6a3278e4729115648997f09cd4005f5
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
66 endfunc
9153
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
67
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
68 func Test_retain_partial()
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
69 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
70 call test_garbagecollect_now()
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
71 sleep 100m
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
72 endfunc
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
73
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
74 func Test_info()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
75 let id = timer_start(1000, 'MyHandler')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
76 let info = timer_info(id)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
77 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
78 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
79 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
80 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
81 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
82 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
83
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
84 let found = 0
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
85 for info in timer_info()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
86 if info['id'] == id
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
87 let found += 1
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
88 endif
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
89 endfor
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
90 call assert_equal(1, found)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
91
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
92 call timer_stop(id)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
93 call assert_equal([], timer_info(id))
9153
c2fe86f2bda1 commit https://github.com/vim/vim/commit/e3188e261569ae512fb1ae2653b57fdd9e259ca3
Christian Brabandt <cb@256bit.org>
parents: 8734
diff changeset
94 endfunc
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
95
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
96 func Test_stopall()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
97 let id1 = timer_start(1000, 'MyHandler')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
98 let id2 = timer_start(2000, 'MyHandler')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
99 let info = timer_info()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
100 call assert_equal(2, len(info))
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
101
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
102 call timer_stopall()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
103 let info = timer_info()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
104 call assert_equal(0, len(info))
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
105 endfunc
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
106
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
107 func Test_paused()
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
108 let g:val = 0
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
109
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
110 let id = timer_start(50, 'MyHandler')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
111 let info = timer_info(id)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
112 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
113
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
114 call timer_pause(id, 1)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
115 let info = timer_info(id)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
116 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
117 sleep 100m
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
118 call assert_equal(0, g:val)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
119
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
120 call timer_pause(id, 0)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
121 let info = timer_info(id)
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
122 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
123
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
124 let slept = WaitFor('g:val == 1')
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
125 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
126 if has('reltime')
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
127 call assert_inrange(0, 30, slept)
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
128 else
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
129 call assert_inrange(0, 10, slept)
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
130 endif
9810
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
131 endfunc
6a28d0c6f929 commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Christian Brabandt <cb@256bit.org>
parents: 9153
diff changeset
132
10066
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
133 func StopMyself(timer)
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
134 let g:called += 1
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
135 if g:called == 2
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
136 call timer_stop(a:timer)
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
137 endif
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
138 endfunc
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
139
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
140 func Test_delete_myself()
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
141 let g:called = 0
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
142 let t = timer_start(10, 'StopMyself', {'repeat': -1})
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
143 call WaitFor('g:called == 2')
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
144 call assert_equal(2, g:called)
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
145 call assert_equal([], timer_info(t))
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
146 endfunc
dc1610dc910f commit https://github.com/vim/vim/commit/417ccd7138d4d230d328de8b0d3892dd82ff1bee
Christian Brabandt <cb@256bit.org>
parents: 10017
diff changeset
147
10122
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
148 func StopTimer1(timer)
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
149 let g:timer2 = timer_start(10, 'StopTimer2')
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
150 " avoid maxfuncdepth error
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
151 call timer_pause(g:timer1, 1)
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
152 sleep 40m
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
153 endfunc
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
154
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
155 func StopTimer2(timer)
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
156 call timer_stop(g:timer1)
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
157 endfunc
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
158
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
159 func Test_stop_in_callback()
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
160 let g:timer1 = timer_start(10, 'StopTimer1')
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
161 sleep 40m
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
162 endfunc
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
163
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
164 func StopTimerAll(timer)
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
165 call timer_stopall()
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
166 endfunc
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
167
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
168 func Test_stop_all_in_callback()
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
169 let g:timer1 = timer_start(10, 'StopTimerAll')
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
170 let info = timer_info()
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
171 call assert_equal(1, len(info))
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
172 sleep 40m
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
173 let info = timer_info()
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
174 call assert_equal(0, len(info))
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
175 endfunc
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
176
11575
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
177 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
178 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
179 endfunc
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
180
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
181 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
182 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
183 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
184 call Resume()
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
185 endfunc
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
186
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
187 func Test_input_in_timer()
0ec755ff1fe2 patch 8.0.0670: can't use input() in a timer callback
Christian Brabandt <cb@256bit.org>
parents: 10178
diff changeset
188 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
189 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
190 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
191 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
192 endfunc
10122
3db463d4df25 commit https://github.com/vim/vim/commit/75537a93e985ef32e6c267b06ce93629855dd983
Christian Brabandt <cb@256bit.org>
parents: 10066
diff changeset
193
11639
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
194 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
195 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
196 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
197 return
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
198 endif
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
199 doesnotexist
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
200 endfunc
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
201
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
202 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
203 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
204 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
205 " Timer will be stopped after failing 3 out of 3 times.
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
206 call WaitFor('g:call_count == 3')
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
207 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
208 call assert_equal(3, g:call_count)
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
209 endfunc
71d7b5ed08a0 patch 8.0.0702: an error in a timer can make Vim unusable
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
210
12337
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
211 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
212 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
213 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
214 endfunc
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
215
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
216 func Interrupt(timer)
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
217 call test_feedinput("\<C-C>")
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
218 endfunc
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
219
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
220 func Test_peek_and_get_char()
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
221 if !has('unix') && !has('gui_running')
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
222 return
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
223 endif
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
224 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
225 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
226 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
227 call assert_equal(char2nr('a'), c)
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
228 call timer_stop(intr)
040a892d0eed patch 8.0.1048: no test for what 8.0.1020 fixes
Christian Brabandt <cb@256bit.org>
parents: 11639
diff changeset
229 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
230
9909
3ee84d270ea7 commit https://github.com/vim/vim/commit/9e4d8215d386100ab660d7d11e6620fd148b605e
Christian Brabandt <cb@256bit.org>
parents: 9822
diff changeset
231 " vim: shiftwidth=2 sts=2 expandtab