comparison src/testdir/test_vim9_class.vim @ 33322:9062315f9de1 v9.0.1926

patch 9.0.1926: Vim9: not enough info in error message Commit: https://github.com/vim/vim/commit/696270bcae0c14029030f14a3f3ca2763a2b39de Author: Ernie Rael <errael@raelity.com> Date: Thu Sep 21 16:42:28 2023 +0200 patch 9.0.1926: Vim9: not enough info in error message Problem: Vim9: not enough info in error message Solution: Add class name, change member to variable, quote names closes: #13136 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
author Christian Brabandt <cb@256bit.org>
date Thu, 21 Sep 2023 16:45:09 +0200
parents ab0ecf1bd6b5
children 4e531adb3fac
comparison
equal deleted inserted replaced
33321:85615068771d 33322:9062315f9de1
644 assert_equal(1, inner.value) 644 assert_equal(1, inner.value)
645 enddef 645 enddef
646 646
647 Test_assign_to_nested_typed_member() 647 Test_assign_to_nested_typed_member()
648 END 648 END
649 v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "value"') 649 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable')
650 650
651 # Assignment where target item is read only script level 651 # Assignment where target item is read only script level
652 lines =<< trim END 652 lines =<< trim END
653 vim9script 653 vim9script
654 654
667 var script_inner = Inner.new(0) 667 var script_inner = Inner.new(0)
668 var script_outer = Outer.new(script_inner) 668 var script_outer = Outer.new(script_inner)
669 script_outer.inner.value = 1 669 script_outer.inner.value = 1
670 assert_equal(1, script_inner.value) 670 assert_equal(1, script_inner.value)
671 END 671 END
672 v9.CheckSourceFailure(lines, 'E1335: Member is not writable: value') 672 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable')
673 enddef 673 enddef
674 674
675 def Test_assignment_with_operator() 675 def Test_assignment_with_operator()
676 # Use "+=" to assign to a object variable 676 # Use "+=" to assign to a object variable
677 var lines =<< trim END 677 var lines =<< trim END
1241 endclass 1241 endclass
1242 1242
1243 var b = B.new() 1243 var b = B.new()
1244 b.Foo() 1244 b.Foo()
1245 END 1245 END
1246 v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "ro_class_var"') 1246 v9.CheckSourceFailure(lines, 'E1335: Variable "ro_class_var" in class "A" is not writable')
1247 1247
1248 # A private class variable cannot be accessed from a child class 1248 # A private class variable cannot be accessed from a child class
1249 lines =<< trim END 1249 lines =<< trim END
1250 vim9script 1250 vim9script
1251 class A 1251 class A
4267 var a = A.new() 4267 var a = A.new()
4268 a.val = 20 4268 a.val = 20
4269 enddef 4269 enddef
4270 T() 4270 T()
4271 END 4271 END
4272 v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "val"') 4272 v9.CheckSourceFailure(lines, 'E1335: Variable "val" in class "A" is not writable')
4273 enddef 4273 enddef
4274 4274
4275 " Test for reading and writing a class member from a def function 4275 " Test for reading and writing a class member from a def function
4276 def Test_modify_class_member_from_def_function() 4276 def Test_modify_class_member_from_def_function()
4277 var lines =<< trim END 4277 var lines =<< trim END
5539 enddef 5539 enddef
5540 5540
5541 var d = D.new() 5541 var d = D.new()
5542 T(d) 5542 T(d)
5543 END 5543 END
5544 v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "value"') 5544 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "A" is not writable')
5545 enddef 5545 enddef
5546 5546
5547 " Test for calling methods using a null object 5547 " Test for calling methods using a null object
5548 def Test_null_object_method_call() 5548 def Test_null_object_method_call()
5549 # Calling a object method using a null object in script context 5549 # Calling a object method using a null object in script context