diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-14 18:24:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 18:24:44 +0800 |
commit | c15939c1f7479be6c1e0a73126b4d62aece28f74 (patch) | |
tree | dd54e88754d71073fb58224fc0ba2891ef0ca7ed /test/old/testdir/test_expr.vim | |
parent | 7caf0eafd83b5a92f2ff219b3a64ffae4174b9af (diff) | |
parent | 3be966f725bfefd7215acd0aad155c94b813d53f (diff) | |
download | rneovim-c15939c1f7479be6c1e0a73126b4d62aece28f74.tar.gz rneovim-c15939c1f7479be6c1e0a73126b4d62aece28f74.tar.bz2 rneovim-c15939c1f7479be6c1e0a73126b4d62aece28f74.zip |
Merge pull request #23084 from zeertzjq/vim-8.2.1794
vim-patch:8.2.{1794,1798},9.0.1452
Diffstat (limited to 'test/old/testdir/test_expr.vim')
-rw-r--r-- | test/old/testdir/test_expr.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/old/testdir/test_expr.vim b/test/old/testdir/test_expr.vim index 292a504df9..1810cf6741 100644 --- a/test/old/testdir/test_expr.vim +++ b/test/old/testdir/test_expr.vim @@ -39,6 +39,38 @@ 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) + call assert_equal('yes', 'yes' ?? 456) + call assert_equal(0z00, 0z00 ?? 456) + call assert_equal([1], [1] ?? 456) + call assert_equal(#{one: 1}, #{one: 1} ?? 456) + if has('float') + call assert_equal(0.1, 0.1 ?? 456) + endif + + call assert_equal(456, v:false ?? 456) + call assert_equal(456, 0 ?? 456) + call assert_equal(456, '' ?? 456) + call assert_equal(456, 0z ?? 456) + call assert_equal(456, [] ?? 456) + call assert_equal(456, {} ?? 456) + if has('float') + call assert_equal(456, 0.0 ?? 456) + endif +endfunc + func Test_dict() let d = {'': 'empty', 'a': 'a', 0: 'zero'} call assert_equal('empty', d['']) |