Mercurial > vim
comparison src/testdir/test_functions.vim @ 17914:af3d441845cd v8.1.1953
patch 8.1.1953: more functions can be used as a method
Commit: https://github.com/vim/vim/commit/f9f24ce7a0e5988fedf2e2ff751818f9b07510a6
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 31 21:17:39 2019 +0200
patch 8.1.1953: more functions can be used as a method
Problem: More functions can be used as a method.
Solution: Allow more functions to be used as a method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 31 Aug 2019 21:30:04 +0200 |
parents | 521ce0d887e5 |
children | 2e53305f2239 |
comparison
equal
deleted
inserted
replaced
17913:be8ab5bb74ce | 17914:af3d441845cd |
---|---|
1067 endif | 1067 endif |
1068 endfunc | 1068 endfunc |
1069 | 1069 |
1070 func Test_hlexists() | 1070 func Test_hlexists() |
1071 call assert_equal(0, hlexists('does_not_exist')) | 1071 call assert_equal(0, hlexists('does_not_exist')) |
1072 call assert_equal(0, hlexists('Number')) | 1072 call assert_equal(0, 'Number'->hlexists()) |
1073 call assert_equal(0, highlight_exists('does_not_exist')) | 1073 call assert_equal(0, highlight_exists('does_not_exist')) |
1074 call assert_equal(0, highlight_exists('Number')) | 1074 call assert_equal(0, highlight_exists('Number')) |
1075 syntax on | 1075 syntax on |
1076 call assert_equal(0, hlexists('does_not_exist')) | 1076 call assert_equal(0, hlexists('does_not_exist')) |
1077 call assert_equal(1, hlexists('Number')) | 1077 call assert_equal(1, hlexists('Number')) |
1100 endfunc | 1100 endfunc |
1101 | 1101 |
1102 func Test_inputlist() | 1102 func Test_inputlist() |
1103 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx') | 1103 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx') |
1104 call assert_equal(1, c) | 1104 call assert_equal(1, c) |
1105 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx') | 1105 call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx') |
1106 call assert_equal(2, c) | 1106 call assert_equal(2, c) |
1107 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx') | 1107 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx') |
1108 call assert_equal(3, c) | 1108 call assert_equal(3, c) |
1109 | 1109 |
1110 call assert_fails('call inputlist("")', 'E686:') | 1110 call assert_fails('call inputlist("")', 'E686:') |
1277 let @q = "W" | 1277 let @q = "W" |
1278 let g:typed = '' | 1278 let g:typed = '' |
1279 let g:regs = [] | 1279 let g:regs = [] |
1280 func TestFunc() abort | 1280 func TestFunc() abort |
1281 let g:regs += [reg_executing()] | 1281 let g:regs += [reg_executing()] |
1282 let g:typed = input('?') | 1282 let g:typed = '?'->input() |
1283 let g:regs += [reg_executing()] | 1283 let g:regs += [reg_executing()] |
1284 endfunc | 1284 endfunc |
1285 call feedkeys("@qy\<CR>", 'xt') | 1285 call feedkeys("@qy\<CR>", 'xt') |
1286 call assert_equal("y", g:typed) | 1286 call assert_equal("y", g:typed) |
1287 call assert_equal(['q', 'q'], g:regs) | 1287 call assert_equal(['q', 'q'], g:regs) |
1291 unlet g:regs | 1291 unlet g:regs |
1292 | 1292 |
1293 bwipe! | 1293 bwipe! |
1294 delfunc s:save_reg_stat | 1294 delfunc s:save_reg_stat |
1295 unlet s:reg_stat | 1295 unlet s:reg_stat |
1296 endfunc | |
1297 | |
1298 func Test_inputsecret() | |
1299 map W :call TestFunc()<CR> | |
1300 let @q = "W" | |
1301 let g:typed1 = '' | |
1302 let g:typed2 = '' | |
1303 let g:regs = [] | |
1304 func TestFunc() abort | |
1305 let g:typed1 = '?'->inputsecret() | |
1306 let g:typed2 = inputsecret('password: ') | |
1307 endfunc | |
1308 call feedkeys("@qsomething\<CR>else\<CR>", 'xt') | |
1309 call assert_equal("something", g:typed1) | |
1310 call assert_equal("else", g:typed2) | |
1311 delfunc TestFunc | |
1312 unmap W | |
1313 unlet g:typed1 | |
1314 unlet g:typed2 | |
1296 endfunc | 1315 endfunc |
1297 | 1316 |
1298 func Test_libcall_libcallnr() | 1317 func Test_libcall_libcallnr() |
1299 if !has('libcall') | 1318 if !has('libcall') |
1300 return | 1319 return |