Mercurial > vim
diff src/testdir/test_vim9_expr.vim @ 28029:0ed38a4e028d v8.2.4539
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Commit: https://github.com/vim/vim/commit/53ba6ca5b27248680e368340707ad4b32a82591f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 10 19:23:28 2022 +0000
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Problem: When comparing special v:none and v:null are handled the same when
compiling.
Solution: Pass more information so that v:none can be handled differently at
compile time. (issue #9923)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Mar 2022 20:30:04 +0100 |
parents | 53e2bf6032e5 |
children | 4aa79224acd2 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -828,8 +828,22 @@ def Test_expr4_compare_null() v9.CheckDefAndScriptFailure(['echo true != v:null'], 'E1072: Cannot compare bool with special') v9.CheckDefAndScriptFailure(['echo v:null != true'], 'E1072: Cannot compare special with bool') v9.CheckDefAndScriptFailure(['echo false == v:null'], 'E1072: Cannot compare bool with special') - - v9.CheckDefExecAndScriptFailure(['echo [] == v:none'], ['E1072: Cannot compare list with special', 'E691: Can only compare List with List']) +enddef + +def Test_expr4_compare_none() + var lines =<< trim END + assert_false('' == v:none) + assert_false('text' == v:none) + assert_true(v:none == v:none) + assert_false(v:none == '') + assert_false(v:none == 'text') + assert_true(v:none == v:none) + END + v9.CheckDefAndScriptSuccess(lines) + + v9.CheckDefAndScriptFailure(['echo [] == v:none'], 'E1072: Cannot compare list with special') + v9.CheckDefAndScriptFailure(['echo 123 == v:none'], 'E1072: Cannot compare number with special') + v9.CheckDefAndScriptFailure(['echo 0z00 == v:none'], 'E1072: Cannot compare blob with special') enddef def Test_expr4_wrong_type()