Mercurial > vim
diff src/testdir/test_functions.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 | 988e5a868b60 |
children | a6d218f99ff7 |
line wrap: on
line diff
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -266,7 +266,7 @@ endfunc func s:normalize_fname(fname) let ret = substitute(a:fname, '\', '/', 'g') let ret = substitute(ret, '//', '/', 'g') - return tolower(ret) + return ret->tolower() endfunc func Test_resolve_win32() @@ -505,7 +505,7 @@ func Test_toupper() \ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')) " Test with a few lowercase diacritics. - call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả")) + call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", "aàáâãäåāăąǎǟǡả"->toupper()) call assert_equal("BḂḆ", toupper("bḃḇ")) call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč")) call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ")) @@ -568,6 +568,11 @@ func Test_toupper() call toupper("123\xC0\x80\xC0") endfunc +func Test_tr() + call assert_equal('foo', tr('bar', 'bar', 'foo')) + call assert_equal('zxy', 'cab'->tr('abc', 'xyz')) +endfunc + " Tests for the mode() function let current_modes = '' func Save_mode() @@ -1203,7 +1208,7 @@ endfunc func Test_trim() call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B")) - call assert_equal("Testing", trim(" \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B")) + call assert_equal("Testing", " \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"->trim()) call assert_equal("RESERVE", trim("xyz \twwRESERVEzyww \t\t", " wxyz\t")) call assert_equal("wRE \tSERVEzyww", trim("wRE \tSERVEzyww")) call assert_equal("abcd\t xxxx tail", trim(" \tabcd\t xxxx tail")) @@ -1617,7 +1622,7 @@ func Test_bufadd_bufload() call assert_equal([''], getbufline(buf, 1, '$')) let curbuf = bufnr('') - call writefile(['some', 'text'], 'XotherName') + eval ['some', 'text']->writefile('XotherName') let buf = 'XotherName'->bufadd() call assert_notequal(0, buf) eval 'XotherName'->bufexists()->assert_equal(1)