comparison src/testdir/test_expr.vim @ 9892:41c5d59e7e10 v7.4.2220

commit https://github.com/vim/vim/commit/e5a8f35b4286135f3469f3b00a6c2220553d9658 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 16 21:30:54 2016 +0200 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)
author Christian Brabandt <cb@256bit.org>
date Tue, 16 Aug 2016 21:45:06 +0200
parents 560291211303
children b01afb4e8f66
comparison
equal deleted inserted replaced
9891:ec73a26cd6cf 9892:41c5d59e7e10
132 132
133 function Test_printf_64bit() 133 function Test_printf_64bit()
134 if has('num64') 134 if has('num64')
135 call assert_equal("123456789012345", printf('%d', 123456789012345)) 135 call assert_equal("123456789012345", printf('%d', 123456789012345))
136 endif 136 endif
137 endfunc
138
139 function Test_printf_spec_s()
140 " number
141 call assert_equal("1234567890", printf('%s', 1234567890))
142
143 " string
144 call assert_equal("abcdefgi", printf('%s', "abcdefgi"))
145
146 " float
147 if has('float')
148 call assert_equal("1.23", printf('%s', 1.23))
149 endif
150
151 " list
152 let value = [1, 'two', ['three', 4]]
153 call assert_equal(string(value), printf('%s', value))
154
155 " dict
156 let value = {'key1' : 'value1', 'key2' : ['list', 'value'], 'key3' : {'dict' : 'value'}}
157 call assert_equal(string(value), printf('%s', value))
158
159 " funcref
160 call assert_equal('printf', printf('%s', function('printf')))
161
162 " partial
163 call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
137 endfunc 164 endfunc
138 165
139 func Test_substitute_expr() 166 func Test_substitute_expr()
140 let g:val = 'XXX' 167 let g:val = 'XXX'
141 call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', '')) 168 call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', ''))