diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 07:39:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 07:39:41 +0000 |
commit | 00c068502d170f9f9b59c4a68aa12e8835859f6c (patch) | |
tree | 2047fc01b8c70326d9b87b47a575e7e5f2141b62 /src/testdir/test_exists.vim | |
parent | Adding upstream version 2:9.1.0016. (diff) | |
download | vim-00c068502d170f9f9b59c4a68aa12e8835859f6c.tar.xz vim-00c068502d170f9f9b59c4a68aa12e8835859f6c.zip |
Adding upstream version 2:9.1.0199.upstream/2%9.1.0199
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/testdir/test_exists.vim')
-rw-r--r-- | src/testdir/test_exists.vim | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/testdir/test_exists.vim b/src/testdir/test_exists.vim index a735a7d..9cdb3fb 100644 --- a/src/testdir/test_exists.vim +++ b/src/testdir/test_exists.vim @@ -1,5 +1,7 @@ " Tests for the exists() function +import './vim9.vim' as v9 + func Test_exists() augroup myagroup autocmd! BufEnter *.my echo "myfile edited" @@ -334,4 +336,51 @@ func Test_exists_funcarg() call FuncArg_Tests("arg1", "arg2") endfunc +" Test for using exists() with class and object variables and methods. +func Test_exists_class_object() + let lines =<< trim END + vim9script + class A + var var1: number = 10 + static var var2: number = 10 + static def Foo() + enddef + def Bar() + enddef + endclass + + assert_equal(1, exists("A")) + var a = A.new() + assert_equal(1, exists("a")) + + assert_equal(1, exists("a.var1")) + assert_fails('exists("a.var2")', 'E1375: Class variable "var2" accessible only using class "A"') + assert_fails('exists("a.var3")', 'E1326: Variable "var3" not found in object "A"') + assert_equal(1, exists("A.var2")) + assert_fails('exists("A.var1")', 'E1376: Object variable "var1" accessible only using class "A" object') + assert_fails('exists("A.var3")', 'E1337: Class variable "var3" not found in class "A"') + + assert_equal(1, exists("a.Bar")) + assert_fails('exists("a.Barz")', 'E1326: Variable "Barz" not found in object "A"') + assert_fails('exists("a.Foo")', 'E1326: Variable "Foo" not found in object "A"') + assert_equal(1, exists("A.Foo")) + assert_fails('exists("A.Bar")', 'E1337: Class variable "Bar" not found in class "A"') + assert_fails('exists("A.Barz")', 'E1337: Class variable "Barz" not found in class "A"') + + def Baz() + assert_equal(1, exists("A")) + var aa = A.new() + assert_equal(1, exists("A.var2")) + assert_fails('exists("A.var1")', 'E1376: Object variable "var1" accessible only using class "A" object') + assert_fails('exists("A.var3")', 'E1337: Class variable "var3" not found in class "A"') + + assert_equal(1, exists("A.Foo")) + assert_fails('exists("A.Bar")', 'E1337: Class variable "Bar" not found in class "A"') + assert_fails('exists("A.Barz")', 'E1337: Class variable "Barz" not found in class "A"') + enddef + Baz() + END + call v9.CheckSourceSuccess(lines) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |