comparison src/testdir/test_expr.vim @ 22492:0e03ef68e738 v8.2.1794

patch 8.2.1794: no falsy Coalescing operator Commit: https://github.com/vim/vim/commit/92f26c256e06277ff2ec4ce7adea1eb58c85abe0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 3 20:17:30 2020 +0200 patch 8.2.1794: no falsy Coalescing operator Problem: No falsy Coalescing operator. Solution: Add the "??" operator. Fix mistake with function argument count.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Oct 2020 20:30:04 +0200
parents c3f6006bf0ba
children ef8a3177edc1
comparison
equal deleted inserted replaced
22491:2ebfb710e320 22492:0e03ef68e738
38 call assert_false(has('patch-7')) 38 call assert_false(has('patch-7'))
39 call assert_false(has('patch-7.4')) 39 call assert_false(has('patch-7.4'))
40 call assert_false(has('patch-7.4.')) 40 call assert_false(has('patch-7.4.'))
41 call assert_false(has('patch-9.1.0')) 41 call assert_false(has('patch-9.1.0'))
42 call assert_false(has('patch-9.9.1')) 42 call assert_false(has('patch-9.9.1'))
43 endfunc
44
45 func Test_op_falsy()
46 call assert_equal(v:true, v:true ?? 456)
47 call assert_equal(123, 123 ?? 456)
48 call assert_equal('yes', 'yes' ?? 456)
49 call assert_equal(0z00, 0z00 ?? 456)
50 call assert_equal([1], [1] ?? 456)
51 call assert_equal(#{one: 1}, #{one: 1} ?? 456)
52 if has('float')
53 call assert_equal(0.1, 0.1 ?? 456)
54 endif
55
56 call assert_equal(456, v:false ?? 456)
57 call assert_equal(456, 0 ?? 456)
58 call assert_equal(456, '' ?? 456)
59 call assert_equal(456, 0z ?? 456)
60 call assert_equal(456, [] ?? 456)
61 call assert_equal(456, {} ?? 456)
62 if has('float')
63 call assert_equal(456, 0.0 ?? 456)
64 endif
43 endfunc 65 endfunc
44 66
45 func Test_dict() 67 func Test_dict()
46 let d = {'': 'empty', 'a': 'a', 0: 'zero'} 68 let d = {'': 'empty', 'a': 'a', 0: 'zero'}
47 call assert_equal('empty', d['']) 69 call assert_equal('empty', d[''])