diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2024-04-13 17:58:09 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-13 18:04:53 +0200 |
commit | c51578fed8f21cf3c1ff72bbb599dca2db02be84 (patch) | |
tree | 230f9c92871fb512962c94e779591281229656fc /src/testdir/test_vim9_class.vim | |
parent | 122d068585686babd63f0b729759ec269171d464 (diff) |
patch 9.1.0314: Vim9: Can define a class in a functionv9.1.0314
Problem: Vim9: Can define a class in a function
(Doug Kearns)
Solution: Give an error for a class defined in a function,
slightly reword some public error messages
(Yegappan Lakshmanan)
fixes: #13184
fixes: #13326
closes: #14537
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_vim9_class.vim')
-rw-r--r-- | src/testdir/test_vim9_class.vim | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index 6d6d178510..5957f57ae1 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -400,7 +400,7 @@ def Test_class_def_method() enddef endclass END - v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3) + v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3) # Using the "public" keyword when defining a class method lines =<< trim END @@ -410,7 +410,7 @@ def Test_class_def_method() enddef endclass END - v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3) + v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3) # Using the "public" keyword when defining an object protected method lines =<< trim END @@ -420,7 +420,7 @@ def Test_class_def_method() enddef endclass END - v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3) + v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3) # Using the "public" keyword when defining a class protected method lines =<< trim END @@ -430,7 +430,7 @@ def Test_class_def_method() enddef endclass END - v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3) + v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3) # Using a "def" keyword without an object method name lines =<< trim END @@ -1191,7 +1191,7 @@ def Test_instance_variable_access() public var _val = 10 endclass END - v9.CheckSourceFailure(lines, 'E1332: Public variable name cannot start with underscore: public var _val = 10', 3) + v9.CheckSourceFailure(lines, 'E1332: public variable name cannot start with underscore: public var _val = 10', 3) lines =<< trim END vim9script @@ -1287,7 +1287,7 @@ def Test_instance_variable_access() public val = 1 endclass END - v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3) + v9.CheckSourceFailure(lines, 'E1331: public must be followed by "var" or "static"', 3) # Modify a instance variable using the class name in the script context lines =<< trim END @@ -6537,7 +6537,7 @@ def Test_interface_with_unsupported_members() public static var num: number endinterface END - v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3) + v9.CheckSourceFailure(lines, 'E1387: public variable not supported in an interface', 3) lines =<< trim END vim9script @@ -6545,7 +6545,7 @@ def Test_interface_with_unsupported_members() public static var num: number endinterface END - v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3) + v9.CheckSourceFailure(lines, 'E1387: public variable not supported in an interface', 3) lines =<< trim END vim9script @@ -10625,4 +10625,17 @@ def Test_abstract_method_defcompile() v9.CheckScriptFailure(lines, 'E476: Invalid command: pass', 1) enddef +" Test for defining a class in a function +def Test_class_definition_in_a_function() + var lines =<< trim END + vim9script + def Foo() + class A + endclass + enddef + defcompile + END + v9.CheckScriptFailure(lines, 'E1429: Class can only be used in a script', 1) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |