diff src/testdir/test_expr.vim @ 22500:ef8a3177edc1 v8.2.1798

patch 8.2.1798: Vim9: trinary operator condition is too permissive Commit: https://github.com/vim/vim/commit/1310660557470a669cc64b359e20666b116e5dbd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 4 16:06:05 2020 +0200 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().
author Bram Moolenaar <Bram@vim.org>
date Sun, 04 Oct 2020 16:15:04 +0200
parents 0e03ef68e738
children f74978697fb6
line wrap: on
line diff
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -42,6 +42,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)