mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
vim-patch:9.0.1540: reverse() on string doesn't work in compiled function
Problem: reverse() on string doesn't work in compiled function.
Solution: Accept string in argument type check. (Yegappan Lakshmanan,
closes vim/vim#12377)
f9dc278946
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -3150,13 +3150,16 @@ endfunc
|
||||
|
||||
" Test for the reverse() function with a string
|
||||
func Test_string_reverse()
|
||||
call assert_equal('', reverse(v:_null_string))
|
||||
for [s1, s2] in [['', ''], ['a', 'a'], ['ab', 'ba'], ['abc', 'cba'],
|
||||
\ ['abcd', 'dcba'], ['«-«-»-»', '»-»-«-«'],
|
||||
\ ['🇦', '🇦'], ['🇦🇧', '🇧🇦'], ['🇦🇧🇨', '🇨🇧🇦'],
|
||||
\ ['🇦«🇧-🇨»🇩', '🇩»🇨-🇧«🇦']]
|
||||
call assert_equal(s2, reverse(s1))
|
||||
endfor
|
||||
let lines =<< trim END
|
||||
call assert_equal('', reverse(v:_null_string))
|
||||
for [s1, s2] in [['', ''], ['a', 'a'], ['ab', 'ba'], ['abc', 'cba'],
|
||||
\ ['abcd', 'dcba'], ['«-«-»-»', '»-»-«-«'],
|
||||
\ ['🇦', '🇦'], ['🇦🇧', '🇧🇦'], ['🇦🇧🇨', '🇨🇧🇦'],
|
||||
\ ['🇦«🇧-🇨»🇩', '🇩»🇨-🇧«🇦']]
|
||||
call assert_equal(s2, reverse(s1))
|
||||
endfor
|
||||
END
|
||||
call CheckLegacyAndVim9Success(lines)
|
||||
|
||||
" test in latin1 encoding
|
||||
let save_enc = &encoding
|
||||
|
@@ -894,7 +894,7 @@ func Test_reverse_sort_uniq()
|
||||
END
|
||||
call CheckLegacyAndVim9Success(lines)
|
||||
|
||||
call assert_fails('call reverse({})', 'E899:')
|
||||
call assert_fails('call reverse({})', 'E1252:')
|
||||
call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:')
|
||||
call assert_fails("call sort([1, 2], function('min'), 1)", "E1206:")
|
||||
call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:")
|
||||
|
@@ -63,7 +63,7 @@ func Test_dict_method()
|
||||
call assert_equal(2, d->remove("two"))
|
||||
let d.two = 2
|
||||
call assert_fails('let x = d->repeat(2)', 'E731:')
|
||||
call assert_fails('let x = d->reverse()', 'E899:')
|
||||
call assert_fails('let x = d->reverse()', 'E1252:')
|
||||
call assert_fails('let x = d->sort()', 'E686:')
|
||||
call assert_equal("{'one': 1, 'two': 2, 'three': 3}", d->string())
|
||||
call assert_equal(v:t_dict, d->type())
|
||||
|
Reference in New Issue
Block a user