diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-03 20:17:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-03 20:17:30 +0200 |
commit | 92f26c256e06277ff2ec4ce7adea1eb58c85abe0 (patch) | |
tree | b4f9334e90b945a9b727b5a7ade7870b2bb06a00 /src/testdir/test_expr.vim | |
parent | c8fe645c198e2ca55c4e3446efbbdb9b995c63ce (diff) | |
download | vim-git-92f26c256e06277ff2ec4ce7adea1eb58c85abe0.tar.gz |
patch 8.2.1794: no falsy Coalescing operatorv8.2.1794
Problem: No falsy Coalescing operator.
Solution: Add the "??" operator. Fix mistake with function argument count.
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r-- | src/testdir/test_expr.vim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index cfae760d4..1086534dc 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -42,6 +42,28 @@ func Test_version() call assert_false(has('patch-9.9.1')) 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['']) |