mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 00:18:33 +00:00
feat(eval/method): partially port v8.1.2004
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
f6ed61e148
+sound is needed for sound_* functions.
Make swapinfo and swapname take exactly one argument.
Previously, they could erroneously take one or more.
This commit is contained in:
@@ -143,7 +143,7 @@ func Test_str2nr()
|
||||
call assert_equal(-123456789, str2nr('-123456789'))
|
||||
|
||||
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('-101', 2))
|
||||
call assert_equal(-5, str2nr('-0b101', 2))
|
||||
@@ -200,7 +200,7 @@ func Test_strftime()
|
||||
" 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('^\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("%Y", [])', 'E745:')
|
||||
@@ -375,7 +375,7 @@ endfunc
|
||||
func Test_strpart()
|
||||
call assert_equal('de', strpart('abcdefg', 3, 2))
|
||||
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('defg', strpart('abcdefg', 3))
|
||||
|
||||
@@ -809,11 +809,11 @@ endfunc
|
||||
func Test_stridx()
|
||||
call assert_equal(-1, stridx('', 'l'))
|
||||
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(2, stridx('hello', 'l', -1))
|
||||
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(-1, stridx('hello', 'l', 4))
|
||||
call assert_equal(-1, stridx('hello', 'l', 10))
|
||||
@@ -826,7 +826,7 @@ func Test_strridx()
|
||||
call assert_equal(0, strridx('', ''))
|
||||
call assert_equal(5, strridx('hello', ''))
|
||||
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', 3))
|
||||
call assert_equal(2, strridx('hello', 'l', 2))
|
||||
|
Reference in New Issue
Block a user