Mercurial > vim
comparison src/testdir/test_timers.vim @ 18035:11dca9732a48 v8.1.2013
patch 8.1.2013: more functions can be used as methods
Commit: https://github.com/vim/vim/commit/f92e58cadb03156879e9bdbf6341bf662d9c87cc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 8 21:51:41 2019 +0200
patch 8.1.2013: more functions can be used as methods
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 08 Sep 2019 22:00:04 +0200 |
parents | 8a2fb21c23c0 |
children | a76fdc6560c3 |
comparison
equal
deleted
inserted
replaced
18034:834b9558f93c | 18035:11dca9732a48 |
---|---|
69 sleep 100m | 69 sleep 100m |
70 endfunc | 70 endfunc |
71 | 71 |
72 func Test_timer_info() | 72 func Test_timer_info() |
73 let id = timer_start(1000, 'MyHandler') | 73 let id = timer_start(1000, 'MyHandler') |
74 let info = timer_info(id) | 74 let info = id->timer_info() |
75 call assert_equal(id, info[0]['id']) | 75 call assert_equal(id, info[0]['id']) |
76 call assert_equal(1000, info[0]['time']) | 76 call assert_equal(1000, info[0]['time']) |
77 call assert_true(info[0]['remaining'] > 500) | 77 call assert_true(info[0]['remaining'] > 500) |
78 call assert_true(info[0]['remaining'] <= 1000) | 78 call assert_true(info[0]['remaining'] <= 1000) |
79 call assert_equal(1, info[0]['repeat']) | 79 call assert_equal(1, info[0]['repeat']) |
107 | 107 |
108 let id = timer_start(50, 'MyHandler') | 108 let id = timer_start(50, 'MyHandler') |
109 let info = timer_info(id) | 109 let info = timer_info(id) |
110 call assert_equal(0, info[0]['paused']) | 110 call assert_equal(0, info[0]['paused']) |
111 | 111 |
112 call timer_pause(id, 1) | 112 eval id->timer_pause(1) |
113 let info = timer_info(id) | 113 let info = timer_info(id) |
114 call assert_equal(1, info[0]['paused']) | 114 call assert_equal(1, info[0]['paused']) |
115 sleep 100m | 115 sleep 100m |
116 call assert_equal(0, g:val) | 116 call assert_equal(0, g:val) |
117 | 117 |
147 call assert_equal(2, g:called) | 147 call assert_equal(2, g:called) |
148 call assert_equal([], timer_info(t)) | 148 call assert_equal([], timer_info(t)) |
149 endfunc | 149 endfunc |
150 | 150 |
151 func StopTimer1(timer) | 151 func StopTimer1(timer) |
152 let g:timer2 = timer_start(10, 'StopTimer2') | 152 let g:timer2 = 10->timer_start('StopTimer2') |
153 " avoid maxfuncdepth error | 153 " avoid maxfuncdepth error |
154 call timer_pause(g:timer1, 1) | 154 call timer_pause(g:timer1, 1) |
155 sleep 20m | 155 sleep 20m |
156 endfunc | 156 endfunc |
157 | 157 |
260 | 260 |
261 call timer_start(0, 'FeedAndPeek') | 261 call timer_start(0, 'FeedAndPeek') |
262 let intr = timer_start(100, 'Interrupt') | 262 let intr = timer_start(100, 'Interrupt') |
263 let c = getchar() | 263 let c = getchar() |
264 call assert_equal(char2nr('a'), c) | 264 call assert_equal(char2nr('a'), c) |
265 call timer_stop(intr) | 265 eval intr->timer_stop() |
266 endfunc | 266 endfunc |
267 | 267 |
268 func Test_timer_getchar_zero() | 268 func Test_timer_getchar_zero() |
269 if has('win32') && !has('gui_running') | 269 if has('win32') && !has('gui_running') |
270 throw 'Skipped: cannot get low-level input' | 270 throw 'Skipped: cannot get low-level input' |