aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJurica Bradaric <jurica.bradaric@avl.com>2017-03-05 22:20:48 +0100
committerJurica Bradaric <jurica.bradaric@avl.com>2017-03-06 21:35:48 +0100
commit2f80360e9acdb32f63633e8408c00de2ef972b3b (patch)
tree2cbcdbe4dc77dcf40c5622e90bc32cb25b841b9e /src/nvim/testdir
parent483e8257e5a28893bcd1de089715f82798d0f93a (diff)
downloadrneovim-2f80360e9acdb32f63633e8408c00de2ef972b3b.tar.gz
rneovim-2f80360e9acdb32f63633e8408c00de2ef972b3b.tar.bz2
rneovim-2f80360e9acdb32f63633e8408c00de2ef972b3b.zip
vim-patch:7.4.2220
Problem: printf() gives an error when the argument for %s is not a string. (Ozaki Kiichi) Solution: Behave like invoking string() on the argument. (Ken Takata) https://github.com/vim/vim/commit/e5a8f35b4286135f3469f3b00a6c2220553d9658
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_expr.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim
index 7ceef2834f..5aeb934e3a 100644
--- a/src/nvim/testdir/test_expr.vim
+++ b/src/nvim/testdir/test_expr.vim
@@ -107,6 +107,33 @@ func Test_setmatches()
call assert_equal(exp, getmatches())
endfunc
+function Test_printf_spec_s()
+ " number
+ call assert_equal("1234567890", printf('%s', 1234567890))
+
+ " string
+ call assert_equal("abcdefgi", printf('%s', "abcdefgi"))
+
+ " float
+ if has('float')
+ call assert_equal("1.23", printf('%s', 1.23))
+ endif
+
+ " list
+ let value = [1, 'two', ['three', 4]]
+ call assert_equal(string(value), printf('%s', value))
+
+ " dict
+ let value = {'key1' : 'value1', 'key2' : ['list', 'value'], 'key3' : {'dict' : 'value'}}
+ call assert_equal(string(value), printf('%s', value))
+
+ " funcref
+ call assert_equal('printf', printf('%s', function('printf')))
+
+ " partial
+ call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
+endfunc
+
func Test_substitute_expr()
let g:val = 'XXX'
call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', ''))