Mercurial > vim
comparison src/testdir/test_expr.vim @ 19783:546bdeef35f1 v8.2.0448
patch 8.2.0448: various functions not properly tested
Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 25 22:23:46 2020 +0100
patch 8.2.0448: various functions not properly tested
Problem: Various functions not properly tested.
Solution: Add more tests, especially for failures. (Yegappan Lakshmanan,
closes #5843)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 25 Mar 2020 22:30:04 +0100 |
parents | b3e93a05c3ca |
children | 2c4d9ca33769 |
comparison
equal
deleted
inserted
replaced
19782:e5f4316b01dd | 19783:546bdeef35f1 |
---|---|
57 call assert_equal(char2nr('b'), strgetchar('axb', 2)) | 57 call assert_equal(char2nr('b'), strgetchar('axb', 2)) |
58 | 58 |
59 call assert_equal(-1, strgetchar('axb', -1)) | 59 call assert_equal(-1, strgetchar('axb', -1)) |
60 call assert_equal(-1, strgetchar('axb', 3)) | 60 call assert_equal(-1, strgetchar('axb', 3)) |
61 call assert_equal(-1, strgetchar('', 0)) | 61 call assert_equal(-1, strgetchar('', 0)) |
62 call assert_fails("let c=strgetchar([], 1)", 'E730:') | |
63 call assert_fails("let c=strgetchar('axb', [])", 'E745:') | |
62 endfunc | 64 endfunc |
63 | 65 |
64 func Test_strcharpart() | 66 func Test_strcharpart() |
65 call assert_equal('a', strcharpart('axb', 0, 1)) | 67 call assert_equal('a', strcharpart('axb', 0, 1)) |
66 call assert_equal('x', 'axb'->strcharpart(1, 1)) | 68 call assert_equal('x', 'axb'->strcharpart(1, 1)) |
442 func Recurse() | 444 func Recurse() |
443 return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '') | 445 return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '') |
444 endfunc | 446 endfunc |
445 " recursive call works | 447 " recursive call works |
446 call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) | 448 call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) |
449 | |
450 call assert_fails("let s=submatch([])", 'E745:') | |
451 call assert_fails("let s=submatch(2, [])", 'E745:') | |
447 endfunc | 452 endfunc |
448 | 453 |
449 func Test_invalid_submatch() | 454 func Test_invalid_submatch() |
450 " This was causing invalid memory access in Vim-7.4.2232 and older | 455 " This was causing invalid memory access in Vim-7.4.2232 and older |
451 call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:') | 456 call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:') |