forked from aniani/vim
patch 8.1.2004: more functions can be used as methods
Problem: More functions can be used as methods. Solution: Make various functions usable as a method.
This commit is contained in:
parent
30e9b3c425
commit
f6ed61e148
@ -8895,7 +8895,11 @@ sound_playevent({name} [, {callback}])
|
|||||||
|
|
||||||
Returns the sound ID, which can be passed to `sound_stop()`.
|
Returns the sound ID, which can be passed to `sound_stop()`.
|
||||||
Returns zero if the sound could not be played.
|
Returns zero if the sound could not be played.
|
||||||
{only available when compiled with the |+sound| feature}
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSoundName()->sound_playevent()
|
||||||
|
|
||||||
|
< {only available when compiled with the |+sound| feature}
|
||||||
|
|
||||||
*sound_playfile()*
|
*sound_playfile()*
|
||||||
sound_playfile({path} [, {callback}])
|
sound_playfile({path} [, {callback}])
|
||||||
@ -8903,6 +8907,10 @@ sound_playfile({path} [, {callback}])
|
|||||||
must be a full path. On Ubuntu you may find files to play
|
must be a full path. On Ubuntu you may find files to play
|
||||||
with this command: >
|
with this command: >
|
||||||
:!find /usr/share/sounds -type f | grep -v index.theme
|
:!find /usr/share/sounds -type f | grep -v index.theme
|
||||||
|
|
||||||
|
< Can also be used as a |method|: >
|
||||||
|
GetSoundPath()->sound_playfile()
|
||||||
|
|
||||||
< {only available when compiled with the |+sound| feature}
|
< {only available when compiled with the |+sound| feature}
|
||||||
|
|
||||||
|
|
||||||
@ -8913,7 +8921,10 @@ sound_stop({id}) *sound_stop()*
|
|||||||
On MS-Windows, this does not work for event sound started by
|
On MS-Windows, this does not work for event sound started by
|
||||||
`sound_playevent()`. To stop event sounds, use `sound_clear()`.
|
`sound_playevent()`. To stop event sounds, use `sound_clear()`.
|
||||||
|
|
||||||
{only available when compiled with the |+sound| feature}
|
Can also be used as a |method|: >
|
||||||
|
soundid->sound_stop()
|
||||||
|
|
||||||
|
< {only available when compiled with the |+sound| feature}
|
||||||
|
|
||||||
*soundfold()*
|
*soundfold()*
|
||||||
soundfold({word})
|
soundfold({word})
|
||||||
@ -8924,6 +8935,9 @@ soundfold({word})
|
|||||||
This can be used for making spelling suggestions. Note that
|
This can be used for making spelling suggestions. Note that
|
||||||
the method can be quite slow.
|
the method can be quite slow.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWord()->soundfold()
|
||||||
|
<
|
||||||
*spellbadword()*
|
*spellbadword()*
|
||||||
spellbadword([{sentence}])
|
spellbadword([{sentence}])
|
||||||
Without argument: The result is the badly spelled word under
|
Without argument: The result is the badly spelled word under
|
||||||
@ -8950,6 +8964,9 @@ spellbadword([{sentence}])
|
|||||||
'spell' option must be set and the value of 'spelllang' is
|
'spell' option must be set and the value of 'spelllang' is
|
||||||
used.
|
used.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->spellbadword()
|
||||||
|
<
|
||||||
*spellsuggest()*
|
*spellsuggest()*
|
||||||
spellsuggest({word} [, {max} [, {capital}]])
|
spellsuggest({word} [, {max} [, {capital}]])
|
||||||
Return a |List| with spelling suggestions to replace {word}.
|
Return a |List| with spelling suggestions to replace {word}.
|
||||||
@ -8973,6 +8990,8 @@ spellsuggest({word} [, {max} [, {capital}]])
|
|||||||
'spell' option must be set and the values of 'spelllang' and
|
'spell' option must be set and the values of 'spelllang' and
|
||||||
'spellsuggest' are used.
|
'spellsuggest' are used.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWord()->spellsuggest()
|
||||||
|
|
||||||
split({expr} [, {pattern} [, {keepempty}]]) *split()*
|
split({expr} [, {pattern} [, {keepempty}]]) *split()*
|
||||||
Make a |List| out of {expr}. When {pattern} is omitted or
|
Make a |List| out of {expr}. When {pattern} is omitted or
|
||||||
@ -9069,6 +9088,19 @@ str2nr({expr} [, {base}]) *str2nr()*
|
|||||||
leading "0b" or "0B" is ignored.
|
leading "0b" or "0B" is ignored.
|
||||||
Text after the number is silently ignored.
|
Text after the number is silently ignored.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->str2nr()
|
||||||
|
|
||||||
|
strcharpart({src}, {start} [, {len}]) *strcharpart()*
|
||||||
|
Like |strpart()| but using character index and length instead
|
||||||
|
of byte index and length.
|
||||||
|
When a character index is used where a character does not
|
||||||
|
exist it is assumed to be one character. For example: >
|
||||||
|
strcharpart('abc', -1, 2)
|
||||||
|
< results in 'a'.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->strcharpart(5)
|
||||||
|
|
||||||
strchars({expr} [, {skipcc}]) *strchars()*
|
strchars({expr} [, {skipcc}]) *strchars()*
|
||||||
The result is a Number, which is the number of characters
|
The result is a Number, which is the number of characters
|
||||||
@ -9094,13 +9126,8 @@ strchars({expr} [, {skipcc}]) *strchars()*
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
<
|
<
|
||||||
strcharpart({src}, {start} [, {len}]) *strcharpart()*
|
Can also be used as a |method|: >
|
||||||
Like |strpart()| but using character index and length instead
|
GetText()->strchars()
|
||||||
of byte index and length.
|
|
||||||
When a character index is used where a character does not
|
|
||||||
exist it is assumed to be one character. For example: >
|
|
||||||
strcharpart('abc', -1, 2)
|
|
||||||
< results in 'a'.
|
|
||||||
|
|
||||||
strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
|
strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
|
||||||
The result is a Number, which is the number of display cells
|
The result is a Number, which is the number of display cells
|
||||||
@ -9115,6 +9142,9 @@ strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
|
|||||||
Ambiguous, this function's return value depends on 'ambiwidth'.
|
Ambiguous, this function's return value depends on 'ambiwidth'.
|
||||||
Also see |strlen()|, |strwidth()| and |strchars()|.
|
Also see |strlen()|, |strwidth()| and |strchars()|.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->strdisplaywidth()
|
||||||
|
|
||||||
strftime({format} [, {time}]) *strftime()*
|
strftime({format} [, {time}]) *strftime()*
|
||||||
The result is a String, which is a formatted date and time, as
|
The result is a String, which is a formatted date and time, as
|
||||||
specified by the {format} string. The given {time} is used,
|
specified by the {format} string. The given {time} is used,
|
||||||
@ -9134,12 +9164,18 @@ strftime({format} [, {time}]) *strftime()*
|
|||||||
< Not available on all systems. To check use: >
|
< Not available on all systems. To check use: >
|
||||||
:if exists("*strftime")
|
:if exists("*strftime")
|
||||||
|
|
||||||
|
< Can also be used as a |method|: >
|
||||||
|
GetFormat()->strftime()
|
||||||
|
|
||||||
strgetchar({str}, {index}) *strgetchar()*
|
strgetchar({str}, {index}) *strgetchar()*
|
||||||
Get character {index} from {str}. This uses a character
|
Get character {index} from {str}. This uses a character
|
||||||
index, not a byte index. Composing characters are considered
|
index, not a byte index. Composing characters are considered
|
||||||
separate characters here.
|
separate characters here.
|
||||||
Also see |strcharpart()| and |strchars()|.
|
Also see |strcharpart()| and |strchars()|.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->strgetchar(5)
|
||||||
|
|
||||||
stridx({haystack}, {needle} [, {start}]) *stridx()*
|
stridx({haystack}, {needle} [, {start}]) *stridx()*
|
||||||
The result is a Number, which gives the byte index in
|
The result is a Number, which gives the byte index in
|
||||||
{haystack} of the first occurrence of the String {needle}.
|
{haystack} of the first occurrence of the String {needle}.
|
||||||
@ -9159,6 +9195,8 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
|
|||||||
stridx() works similar to the C function strstr(). When used
|
stridx() works similar to the C function strstr(). When used
|
||||||
with a single character it works similar to strchr().
|
with a single character it works similar to strchr().
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetHaystack()->stridx(needle)
|
||||||
*string()*
|
*string()*
|
||||||
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
||||||
Float, String, Blob or a composition of them, then the result
|
Float, String, Blob or a composition of them, then the result
|
||||||
@ -9211,6 +9249,9 @@ strpart({src}, {start} [, {len}]) *strpart()*
|
|||||||
example, to get three bytes under and after the cursor: >
|
example, to get three bytes under and after the cursor: >
|
||||||
strpart(getline("."), col(".") - 1, 3)
|
strpart(getline("."), col(".") - 1, 3)
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetText()->strpart(5)
|
||||||
|
|
||||||
strridx({haystack}, {needle} [, {start}]) *strridx()*
|
strridx({haystack}, {needle} [, {start}]) *strridx()*
|
||||||
The result is a Number, which gives the byte index in
|
The result is a Number, which gives the byte index in
|
||||||
{haystack} of the last occurrence of the String {needle}.
|
{haystack} of the last occurrence of the String {needle}.
|
||||||
@ -9229,6 +9270,9 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
|
|||||||
When used with a single character it works similar to the C
|
When used with a single character it works similar to the C
|
||||||
function strrchr().
|
function strrchr().
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetHaystack()->strridx(needle)
|
||||||
|
|
||||||
strtrans({expr}) *strtrans()*
|
strtrans({expr}) *strtrans()*
|
||||||
The result is a String, which is {expr} with all unprintable
|
The result is a String, which is {expr} with all unprintable
|
||||||
characters translated into printable characters |'isprint'|.
|
characters translated into printable characters |'isprint'|.
|
||||||
@ -9277,6 +9321,9 @@ submatch({nr} [, {list}]) *submatch()* *E935*
|
|||||||
< This finds the first number in the line and adds one to it.
|
< This finds the first number in the line and adds one to it.
|
||||||
A line break is included as a newline character.
|
A line break is included as a newline character.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetNr()->submatch()
|
||||||
|
|
||||||
substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
|
substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
|
||||||
The result is a String, which is a copy of {expr}, in which
|
The result is a String, which is a copy of {expr}, in which
|
||||||
the first match of {pat} is replaced with {sub}.
|
the first match of {pat} is replaced with {sub}.
|
||||||
@ -9340,6 +9387,9 @@ swapinfo({fname}) *swapinfo()*
|
|||||||
Not a swap file: does not contain correct block ID
|
Not a swap file: does not contain correct block ID
|
||||||
Magic number mismatch: Info in first block is invalid
|
Magic number mismatch: Info in first block is invalid
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetFilename()->swapinfo()
|
||||||
|
|
||||||
swapname({expr}) *swapname()*
|
swapname({expr}) *swapname()*
|
||||||
The result is the swap file path of the buffer {expr}.
|
The result is the swap file path of the buffer {expr}.
|
||||||
For the use of {expr}, see |bufname()| above.
|
For the use of {expr}, see |bufname()| above.
|
||||||
@ -9347,6 +9397,9 @@ swapname({expr}) *swapname()*
|
|||||||
|:swapname| (unless no swap file).
|
|:swapname| (unless no swap file).
|
||||||
If buffer {expr} has no swap file, returns an empty string.
|
If buffer {expr} has no swap file, returns an empty string.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetBufname()->swapname()
|
||||||
|
|
||||||
synID({lnum}, {col}, {trans}) *synID()*
|
synID({lnum}, {col}, {trans}) *synID()*
|
||||||
The result is a Number, which is the syntax ID at the position
|
The result is a Number, which is the syntax ID at the position
|
||||||
{lnum} and {col} in the current window.
|
{lnum} and {col} in the current window.
|
||||||
|
@ -715,38 +715,38 @@ static funcentry_T global_functions[] =
|
|||||||
{"sort", 1, 3, FEARG_1, f_sort},
|
{"sort", 1, 3, FEARG_1, f_sort},
|
||||||
#ifdef FEAT_SOUND
|
#ifdef FEAT_SOUND
|
||||||
{"sound_clear", 0, 0, 0, f_sound_clear},
|
{"sound_clear", 0, 0, 0, f_sound_clear},
|
||||||
{"sound_playevent", 1, 2, 0, f_sound_playevent},
|
{"sound_playevent", 1, 2, FEARG_1, f_sound_playevent},
|
||||||
{"sound_playfile", 1, 2, 0, f_sound_playfile},
|
{"sound_playfile", 1, 2, FEARG_1, f_sound_playfile},
|
||||||
{"sound_stop", 1, 1, 0, f_sound_stop},
|
{"sound_stop", 1, 1, FEARG_1, f_sound_stop},
|
||||||
#endif
|
#endif
|
||||||
{"soundfold", 1, 1, 0, f_soundfold},
|
{"soundfold", 1, 1, FEARG_1, f_soundfold},
|
||||||
{"spellbadword", 0, 1, 0, f_spellbadword},
|
{"spellbadword", 0, 1, FEARG_1, f_spellbadword},
|
||||||
{"spellsuggest", 1, 3, 0, f_spellsuggest},
|
{"spellsuggest", 1, 3, FEARG_1, f_spellsuggest},
|
||||||
{"split", 1, 3, FEARG_1, f_split},
|
{"split", 1, 3, FEARG_1, f_split},
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
{"sqrt", 1, 1, FEARG_1, f_sqrt},
|
{"sqrt", 1, 1, FEARG_1, f_sqrt},
|
||||||
{"str2float", 1, 1, FEARG_1, f_str2float},
|
{"str2float", 1, 1, FEARG_1, f_str2float},
|
||||||
#endif
|
#endif
|
||||||
{"str2list", 1, 2, FEARG_1, f_str2list},
|
{"str2list", 1, 2, FEARG_1, f_str2list},
|
||||||
{"str2nr", 1, 2, 0, f_str2nr},
|
{"str2nr", 1, 2, FEARG_1, f_str2nr},
|
||||||
{"strcharpart", 2, 3, 0, f_strcharpart},
|
{"strcharpart", 2, 3, FEARG_1, f_strcharpart},
|
||||||
{"strchars", 1, 2, 0, f_strchars},
|
{"strchars", 1, 2, FEARG_1, f_strchars},
|
||||||
{"strdisplaywidth", 1, 2, 0, f_strdisplaywidth},
|
{"strdisplaywidth", 1, 2, FEARG_1, f_strdisplaywidth},
|
||||||
#ifdef HAVE_STRFTIME
|
#ifdef HAVE_STRFTIME
|
||||||
{"strftime", 1, 2, 0, f_strftime},
|
{"strftime", 1, 2, FEARG_1, f_strftime},
|
||||||
#endif
|
#endif
|
||||||
{"strgetchar", 2, 2, 0, f_strgetchar},
|
{"strgetchar", 2, 2, FEARG_1, f_strgetchar},
|
||||||
{"stridx", 2, 3, 0, f_stridx},
|
{"stridx", 2, 3, FEARG_1, f_stridx},
|
||||||
{"string", 1, 1, FEARG_1, f_string},
|
{"string", 1, 1, FEARG_1, f_string},
|
||||||
{"strlen", 1, 1, FEARG_1, f_strlen},
|
{"strlen", 1, 1, FEARG_1, f_strlen},
|
||||||
{"strpart", 2, 3, 0, f_strpart},
|
{"strpart", 2, 3, FEARG_1, f_strpart},
|
||||||
{"strridx", 2, 3, 0, f_strridx},
|
{"strridx", 2, 3, FEARG_1, f_strridx},
|
||||||
{"strtrans", 1, 1, FEARG_1, f_strtrans},
|
{"strtrans", 1, 1, FEARG_1, f_strtrans},
|
||||||
{"strwidth", 1, 1, FEARG_1, f_strwidth},
|
{"strwidth", 1, 1, FEARG_1, f_strwidth},
|
||||||
{"submatch", 1, 2, 0, f_submatch},
|
{"submatch", 1, 2, FEARG_1, f_submatch},
|
||||||
{"substitute", 4, 4, FEARG_1, f_substitute},
|
{"substitute", 4, 4, FEARG_1, f_substitute},
|
||||||
{"swapinfo", 1, 1, 0, f_swapinfo},
|
{"swapinfo", 1, 1, FEARG_1, f_swapinfo},
|
||||||
{"swapname", 1, 1, 0, f_swapname},
|
{"swapname", 1, 1, FEARG_1, f_swapname},
|
||||||
{"synID", 3, 3, 0, f_synID},
|
{"synID", 3, 3, 0, f_synID},
|
||||||
{"synIDattr", 2, 3, FEARG_1, f_synIDattr},
|
{"synIDattr", 2, 3, FEARG_1, f_synIDattr},
|
||||||
{"synIDtrans", 1, 1, FEARG_1, f_synIDtrans},
|
{"synIDtrans", 1, 1, FEARG_1, f_synIDtrans},
|
||||||
|
@ -424,7 +424,7 @@ func Test_breakindent11_vartabs()
|
|||||||
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
|
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
|
||||||
let text = getline(2)
|
let text = getline(2)
|
||||||
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
|
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
|
||||||
call assert_equal(width, strdisplaywidth(text))
|
call assert_equal(width, text->strdisplaywidth())
|
||||||
call s:close_windows('set sbr= vts&')
|
call s:close_windows('set sbr= vts&')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_strgetchar()
|
func Test_strgetchar()
|
||||||
call assert_equal(char2nr('a'), strgetchar('axb', 0))
|
call assert_equal(char2nr('a'), strgetchar('axb', 0))
|
||||||
call assert_equal(char2nr('x'), strgetchar('axb', 1))
|
call assert_equal(char2nr('x'), 'axb'->strgetchar(1))
|
||||||
call assert_equal(char2nr('b'), strgetchar('axb', 2))
|
call assert_equal(char2nr('b'), strgetchar('axb', 2))
|
||||||
|
|
||||||
call assert_equal(-1, strgetchar('axb', -1))
|
call assert_equal(-1, strgetchar('axb', -1))
|
||||||
@ -63,7 +63,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_strcharpart()
|
func Test_strcharpart()
|
||||||
call assert_equal('a', strcharpart('axb', 0, 1))
|
call assert_equal('a', strcharpart('axb', 0, 1))
|
||||||
call assert_equal('x', strcharpart('axb', 1, 1))
|
call assert_equal('x', 'axb'->strcharpart(1, 1))
|
||||||
call assert_equal('b', strcharpart('axb', 2, 1))
|
call assert_equal('b', strcharpart('axb', 2, 1))
|
||||||
call assert_equal('xb', strcharpart('axb', 1))
|
call assert_equal('xb', strcharpart('axb', 1))
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func Test_str2nr()
|
|||||||
call assert_equal(-123456789, str2nr('-123456789'))
|
call assert_equal(-123456789, str2nr('-123456789'))
|
||||||
|
|
||||||
call assert_equal(5, str2nr('101', 2))
|
call assert_equal(5, str2nr('101', 2))
|
||||||
call assert_equal(5, str2nr('0b101', 2))
|
call assert_equal(5, '0b101'->str2nr(2))
|
||||||
call assert_equal(5, str2nr('0B101', 2))
|
call assert_equal(5, str2nr('0B101', 2))
|
||||||
call assert_equal(-5, str2nr('-101', 2))
|
call assert_equal(-5, str2nr('-101', 2))
|
||||||
call assert_equal(-5, str2nr('-0b101', 2))
|
call assert_equal(-5, str2nr('-0b101', 2))
|
||||||
@ -184,7 +184,7 @@ func Test_strftime()
|
|||||||
" of strftime() can be 17 or 18, depending on timezone.
|
" of strftime() can be 17 or 18, depending on timezone.
|
||||||
call assert_match('^2017-01-1[78]$', strftime('%Y-%m-%d', 1484695512))
|
call assert_match('^2017-01-1[78]$', strftime('%Y-%m-%d', 1484695512))
|
||||||
"
|
"
|
||||||
call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', strftime('%Y-%m-%d %H:%M:%S'))
|
call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', '%Y-%m-%d %H:%M:%S'->strftime())
|
||||||
|
|
||||||
call assert_fails('call strftime([])', 'E730:')
|
call assert_fails('call strftime([])', 'E730:')
|
||||||
call assert_fails('call strftime("%Y", [])', 'E745:')
|
call assert_fails('call strftime("%Y", [])', 'E745:')
|
||||||
@ -415,7 +415,7 @@ endfunc
|
|||||||
func Test_strpart()
|
func Test_strpart()
|
||||||
call assert_equal('de', strpart('abcdefg', 3, 2))
|
call assert_equal('de', strpart('abcdefg', 3, 2))
|
||||||
call assert_equal('ab', strpart('abcdefg', -2, 4))
|
call assert_equal('ab', strpart('abcdefg', -2, 4))
|
||||||
call assert_equal('abcdefg', strpart('abcdefg', -2))
|
call assert_equal('abcdefg', 'abcdefg'->strpart(-2))
|
||||||
call assert_equal('fg', strpart('abcdefg', 5, 4))
|
call assert_equal('fg', strpart('abcdefg', 5, 4))
|
||||||
call assert_equal('defg', strpart('abcdefg', 3))
|
call assert_equal('defg', strpart('abcdefg', 3))
|
||||||
|
|
||||||
@ -763,11 +763,11 @@ endfunc
|
|||||||
func Test_stridx()
|
func Test_stridx()
|
||||||
call assert_equal(-1, stridx('', 'l'))
|
call assert_equal(-1, stridx('', 'l'))
|
||||||
call assert_equal(0, stridx('', ''))
|
call assert_equal(0, stridx('', ''))
|
||||||
call assert_equal(0, stridx('hello', ''))
|
call assert_equal(0, 'hello'->stridx(''))
|
||||||
call assert_equal(-1, stridx('hello', 'L'))
|
call assert_equal(-1, stridx('hello', 'L'))
|
||||||
call assert_equal(2, stridx('hello', 'l', -1))
|
call assert_equal(2, stridx('hello', 'l', -1))
|
||||||
call assert_equal(2, stridx('hello', 'l', 0))
|
call assert_equal(2, stridx('hello', 'l', 0))
|
||||||
call assert_equal(2, stridx('hello', 'l', 1))
|
call assert_equal(2, 'hello'->stridx('l', 1))
|
||||||
call assert_equal(3, stridx('hello', 'l', 3))
|
call assert_equal(3, stridx('hello', 'l', 3))
|
||||||
call assert_equal(-1, stridx('hello', 'l', 4))
|
call assert_equal(-1, stridx('hello', 'l', 4))
|
||||||
call assert_equal(-1, stridx('hello', 'l', 10))
|
call assert_equal(-1, stridx('hello', 'l', 10))
|
||||||
@ -780,7 +780,7 @@ func Test_strridx()
|
|||||||
call assert_equal(0, strridx('', ''))
|
call assert_equal(0, strridx('', ''))
|
||||||
call assert_equal(5, strridx('hello', ''))
|
call assert_equal(5, strridx('hello', ''))
|
||||||
call assert_equal(-1, strridx('hello', 'L'))
|
call assert_equal(-1, strridx('hello', 'L'))
|
||||||
call assert_equal(3, strridx('hello', 'l'))
|
call assert_equal(3, 'hello'->strridx('l'))
|
||||||
call assert_equal(3, strridx('hello', 'l', 10))
|
call assert_equal(3, strridx('hello', 'l', 10))
|
||||||
call assert_equal(3, strridx('hello', 'l', 3))
|
call assert_equal(3, strridx('hello', 'l', 3))
|
||||||
call assert_equal(2, strridx('hello', 'l', 2))
|
call assert_equal(2, strridx('hello', 'l', 2))
|
||||||
|
@ -13,13 +13,13 @@ func Test_play_event()
|
|||||||
if has('win32')
|
if has('win32')
|
||||||
throw 'Skipped: Playing event with callback is not supported on Windows'
|
throw 'Skipped: Playing event with callback is not supported on Windows'
|
||||||
endif
|
endif
|
||||||
let id = sound_playevent('bell', 'PlayCallback')
|
let id = 'bell'->sound_playevent('PlayCallback')
|
||||||
if id == 0
|
if id == 0
|
||||||
throw 'Skipped: bell event not available'
|
throw 'Skipped: bell event not available'
|
||||||
endif
|
endif
|
||||||
" Stop it quickly, avoid annoying the user.
|
" Stop it quickly, avoid annoying the user.
|
||||||
sleep 20m
|
sleep 20m
|
||||||
call sound_stop(id)
|
eval id->sound_stop()
|
||||||
sleep 30m
|
sleep 30m
|
||||||
call assert_equal(id, g:id)
|
call assert_equal(id, g:id)
|
||||||
call assert_equal(1, g:result) " sound was aborted
|
call assert_equal(1, g:result) " sound was aborted
|
||||||
@ -35,7 +35,7 @@ func Test_play_silent()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" play until the end
|
" play until the end
|
||||||
let id2 = sound_playfile(fname, 'PlayCallback')
|
let id2 = fname->sound_playfile('PlayCallback')
|
||||||
call assert_true(id2 > 0)
|
call assert_true(id2 > 0)
|
||||||
sleep 500m
|
sleep 500m
|
||||||
call assert_equal(id2, g:id)
|
call assert_equal(id2, g:id)
|
||||||
|
@ -73,7 +73,7 @@ func Test_spellbadword()
|
|||||||
set spell
|
set spell
|
||||||
|
|
||||||
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
|
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
|
||||||
call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
|
call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
|
||||||
|
|
||||||
set spelllang=en
|
set spelllang=en
|
||||||
call assert_equal(['', ''], spellbadword('centre'))
|
call assert_equal(['', ''], spellbadword('centre'))
|
||||||
@ -179,7 +179,7 @@ func Test_zz_basic()
|
|||||||
\ )
|
\ )
|
||||||
|
|
||||||
call assert_equal("gebletegek", soundfold('goobledygoook'))
|
call assert_equal("gebletegek", soundfold('goobledygoook'))
|
||||||
call assert_equal("kepereneven", soundfold('kóopërÿnôven'))
|
call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
|
||||||
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
|
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ func TestGoodBadBase()
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
let prevbad = bad
|
let prevbad = bad
|
||||||
let lst = spellsuggest(bad, 3)
|
let lst = bad->spellsuggest(3)
|
||||||
normal mm
|
normal mm
|
||||||
|
|
||||||
call add(result, [bad, lst])
|
call add(result, [bad, lst])
|
||||||
|
@ -337,7 +337,7 @@ func Test_sub_replace_5()
|
|||||||
\ substitute('A123456789',
|
\ substitute('A123456789',
|
||||||
\ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
\ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
||||||
\ '\=string([submatch(0, 1), submatch(9, 1), ' .
|
\ '\=string([submatch(0, 1), submatch(9, 1), ' .
|
||||||
\ 'submatch(8, 1), submatch(7, 1), submatch(6, 1), ' .
|
\ 'submatch(8, 1), 7->submatch(1), submatch(6, 1), ' .
|
||||||
\ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' .
|
\ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' .
|
||||||
\ 'submatch(2, 1), submatch(1, 1)])',
|
\ 'submatch(2, 1), submatch(1, 1)])',
|
||||||
\ ''))
|
\ ''))
|
||||||
|
@ -111,7 +111,7 @@ func Test_swapinfo()
|
|||||||
w
|
w
|
||||||
let fname = s:swapname()
|
let fname = s:swapname()
|
||||||
call assert_match('Xswapinfo', fname)
|
call assert_match('Xswapinfo', fname)
|
||||||
let info = swapinfo(fname)
|
let info = fname->swapinfo()
|
||||||
|
|
||||||
let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
|
let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
|
||||||
call assert_equal(ver, info.version)
|
call assert_equal(ver, info.version)
|
||||||
@ -153,7 +153,7 @@ func Test_swapname()
|
|||||||
let buf = bufnr('%')
|
let buf = bufnr('%')
|
||||||
let expected = s:swapname()
|
let expected = s:swapname()
|
||||||
wincmd p
|
wincmd p
|
||||||
call assert_equal(expected, swapname(buf))
|
call assert_equal(expected, buf->swapname())
|
||||||
|
|
||||||
new Xtest3
|
new Xtest3
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
|
@ -17,7 +17,7 @@ func Test_strchars()
|
|||||||
let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
|
let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
|
||||||
for i in range(len(inp))
|
for i in range(len(inp))
|
||||||
call assert_equal(exp[i][0], strchars(inp[i]))
|
call assert_equal(exp[i][0], strchars(inp[i]))
|
||||||
call assert_equal(exp[i][1], strchars(inp[i], 0))
|
call assert_equal(exp[i][1], inp[i]->strchars(0))
|
||||||
call assert_equal(exp[i][2], strchars(inp[i], 1))
|
call assert_equal(exp[i][2], strchars(inp[i], 1))
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2004,
|
||||||
/**/
|
/**/
|
||||||
2003,
|
2003,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user