aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-14 17:53:47 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-14 18:04:12 +0800
commitf12afd8e166e503fa0df80f932d338558afe3c3f (patch)
tree98c343de9d9f15eff7f0f6c6805b32b07d78c9c0
parentd6e2804ab4f8810293dbcd748bfb938d9e0c3d52 (diff)
downloadrneovim-f12afd8e166e503fa0df80f932d338558afe3c3f.tar.gz
rneovim-f12afd8e166e503fa0df80f932d338558afe3c3f.tar.bz2
rneovim-f12afd8e166e503fa0df80f932d338558afe3c3f.zip
vim-patch:8.2.1798: Vim9: trinary operator condition is too permissive
Problem: Vim9: trinary operator condition is too permissive. Solution: Use tv_get_bool_chk(). https://github.com/vim/vim/commit/1310660557470a669cc64b359e20666b116e5dbd Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--test/old/testdir/test_expr.vim10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/old/testdir/test_expr.vim b/test/old/testdir/test_expr.vim
index 66a59f2c44..1810cf6741 100644
--- a/test/old/testdir/test_expr.vim
+++ b/test/old/testdir/test_expr.vim
@@ -39,6 +39,16 @@ func Test_version()
call assert_false(has('patch-9.9.1'))
endfunc
+func Test_op_trinary()
+ call assert_equal('yes', 1 ? 'yes' : 'no')
+ call assert_equal('no', 0 ? 'yes' : 'no')
+ call assert_equal('no', 'x' ? 'yes' : 'no')
+ call assert_equal('yes', '1x' ? 'yes' : 'no')
+
+ call assert_fails('echo [1] ? "yes" : "no"', 'E745:')
+ call assert_fails('echo {} ? "yes" : "no"', 'E728:')
+endfunc
+
func Test_op_falsy()
call assert_equal(v:true, v:true ?? 456)
call assert_equal(123, 123 ?? 456)