Mercurial > vim
comparison src/testdir/test_functions.vim @ 26650:a07323eb647f v8.2.3854
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Commit: https://github.com/vim/vim/commit/86b3ab4fa0de3e8884ab6a6ced2a70592b937d0f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 19 18:33:23 2021 +0000
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Problem: Vim9: inconsistent arguments for test functions.
Solution: When :def function and script have different arguments use a list
with two items instead of a separate function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Dec 2021 19:45:03 +0100 |
parents | a753cca75c69 |
children | dfaba853a792 |
comparison
equal
deleted
inserted
replaced
26649:8a10ad703e92 | 26650:a07323eb647f |
---|---|
172 call assert_fails('call strwidth({})', 'E731:') | 172 call assert_fails('call strwidth({})', 'E731:') |
173 endfor | 173 endfor |
174 | 174 |
175 if has('float') | 175 if has('float') |
176 call assert_equal(3, strwidth(1.2)) | 176 call assert_equal(3, strwidth(1.2)) |
177 call CheckDefAndScriptFailure2(['echo strwidth(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') | 177 call CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
178 endif | 178 endif |
179 | 179 |
180 set ambiwidth& | 180 set ambiwidth& |
181 endfunc | 181 endfunc |
182 | 182 |
239 | 239 |
240 call assert_fails('call str2nr([])', 'E730:') | 240 call assert_fails('call str2nr([])', 'E730:') |
241 call assert_fails('call str2nr({->2})', 'E729:') | 241 call assert_fails('call str2nr({->2})', 'E729:') |
242 if has('float') | 242 if has('float') |
243 call assert_equal(1, str2nr(1.2)) | 243 call assert_equal(1, str2nr(1.2)) |
244 call CheckDefAndScriptFailure2(['echo str2nr(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') | 244 call CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
245 endif | 245 endif |
246 call assert_fails('call str2nr(10, [])', 'E745:') | 246 call assert_fails('call str2nr(10, [])', 'E745:') |
247 endfunc | 247 endfunc |
248 | 248 |
249 func Test_strftime() | 249 func Test_strftime() |
501 call assert_fails('call simplify({->0})', 'E729:') | 501 call assert_fails('call simplify({->0})', 'E729:') |
502 call assert_fails('call simplify([])', 'E730:') | 502 call assert_fails('call simplify([])', 'E730:') |
503 call assert_fails('call simplify({})', 'E731:') | 503 call assert_fails('call simplify({})', 'E731:') |
504 if has('float') | 504 if has('float') |
505 call assert_equal('1.2', simplify(1.2)) | 505 call assert_equal('1.2', simplify(1.2)) |
506 call CheckDefAndScriptFailure2(['echo simplify(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1') | 506 call CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
507 endif | 507 endif |
508 endfunc | 508 endfunc |
509 | 509 |
510 func Test_pathshorten() | 510 func Test_pathshorten() |
511 call assert_equal('', pathshorten('')) | 511 call assert_equal('', pathshorten('')) |