summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_expr.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-03 20:17:30 +0200
committerBram Moolenaar <Bram@vim.org>2020-10-03 20:17:30 +0200
commit92f26c256e06277ff2ec4ce7adea1eb58c85abe0 (patch)
treeb4f9334e90b945a9b727b5a7ade7870b2bb06a00 /src/testdir/test_expr.vim
parentc8fe645c198e2ca55c4e3446efbbdb9b995c63ce (diff)
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.vim22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index cfae760d49..1086534dca 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[''])