diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-09 11:56:21 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-09 11:56:21 +0000 |
commit | f3507a517c38bee5498736607ead64c8ae6b5941 (patch) | |
tree | cad30f34ea6d915800ce7170d28acf09d43b6976 /src/testdir/test_expr.vim | |
parent | 1588bc8ebee22f2855f27273fc2234fff370f86c (diff) |
patch 8.2.4530: making comparison with null work changes legacy behaviorv8.2.4530
Problem: Making comparison with null work changes legacy behavior.
Solution: Only use the better comparison in Vim9 script. (closes #9910)
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r-- | src/testdir/test_expr.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 5f2020db42..3c61d27036 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -181,6 +181,38 @@ func Test_loop_over_null_list() call v9.CheckScriptFailure(lines, 'E121: Undefined variable: null_list') endfunc +func Test_compare_with_null() + let s:value = v:null + call assert_true(s:value == v:null) + let s:value = v:true + call assert_false(s:value == v:null) + let s:value = v:none + call assert_false(s:value == v:null) + let s:value = 0 + call assert_true(s:value == v:null) + if has('float') + let s:value = 0.0 + call assert_true(s:value == v:null) + endif + let s:value = '' + call assert_false(s:value == v:null) + let s:value = 0z + call assert_false(s:value == v:null) + let s:value = [] + call assert_false(s:value == v:null) + let s:value = {} + call assert_false(s:value == v:null) + let s:value = function('len') + call assert_false(s:value == v:null) + if has('job') + let s:value = test_null_job() + call assert_true(s:value == v:null) + let s:value = test_null_channel() + call assert_true(s:value == v:null) + endif + unlet s:value +endfunc + func Test_setreg_null_list() let lines =<< trim END call setreg('x', test_null_list()) |