summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-10 21:57:54 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-10 21:57:54 +0200
commit3e06a1e2a8c0854c881574f33363e00264db1f1d (patch)
tree157355f93618af7809f52aa3bf2a83d0ce79867e /src/testdir
parent6f8f7337c1211692d508239eb4cbc8a6f67de497 (diff)
downloadvim-git-3e06a1e2a8c0854c881574f33363e00264db1f1d.tar.gz
patch 8.2.1416: Vim9: boolean evaluation does not work as intendedv8.2.1416
Problem: Vim9: boolean evaluation does not work as intended. Solution: Use tv2bool() in Vim9 script. (closes #6681)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_vim9_expr.vim54
-rw-r--r--src/testdir/vim9.vim8
2 files changed, 37 insertions, 25 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index aa5997318..d2d2e0b1e 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1750,31 +1750,35 @@ enddef
def Test_expr7_not()
- assert_equal(true, !'')
- assert_equal(true, ![])
- assert_equal(false, !'asdf')
- assert_equal(false, ![2])
- assert_equal(true, !!'asdf')
- assert_equal(true, !![2])
-
- assert_equal(true, !test_null_partial())
- assert_equal(false, !{-> 'yes'})
-
- assert_equal(true, !test_null_dict())
- assert_equal(true, !{})
- assert_equal(false, !{'yes': 'no'})
-
- if has('channel')
- assert_equal(true, !test_null_job())
- assert_equal(true, !test_null_channel())
- endif
-
- assert_equal(true, !test_null_blob())
- assert_equal(true, !0z)
- assert_equal(false, !0z01)
-
- assert_equal(true, !test_void())
- assert_equal(true, !test_unknown())
+ let lines =<< trim END
+ assert_equal(true, !'')
+ assert_equal(true, ![])
+ assert_equal(false, !'asdf')
+ assert_equal(false, ![2])
+ assert_equal(true, !!'asdf')
+ assert_equal(true, !![2])
+
+ assert_equal(true, !test_null_partial())
+ assert_equal(false, !{-> 'yes'})
+
+ assert_equal(true, !test_null_dict())
+ assert_equal(true, !{})
+ assert_equal(false, !{'yes': 'no'})
+
+ if has('channel')
+ assert_equal(true, !test_null_job())
+ assert_equal(true, !test_null_channel())
+ endif
+
+ assert_equal(true, !test_null_blob())
+ assert_equal(true, !0z)
+ assert_equal(false, !0z01)
+
+ assert_equal(true, !test_void())
+ assert_equal(true, !test_unknown())
+ END
+ CheckDefSuccess(lines)
+ CheckScriptSuccess(['vim9script'] + lines)
enddef
func Test_expr7_fails()
diff --git a/src/testdir/vim9.vim b/src/testdir/vim9.vim
index fdad9f7c3..448aa3db9 100644
--- a/src/testdir/vim9.vim
+++ b/src/testdir/vim9.vim
@@ -1,5 +1,13 @@
" Utility functions for testing vim9 script
+" Check that "lines" inside ":def" has no error.
+func CheckDefSuccess(lines)
+ call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef')
+ so Xdef
+ call Func()
+ call delete('Xdef')
+endfunc
+
" Check that "lines" inside ":def" results in an "error" message.
func CheckDefFailure(lines, error)
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef')