@@ -7510,6 +7510,21 @@ def Test_object_funcref()
75107510 END
75117511 v9.CheckSourceSuccess (lines )
75127512
7513+ # Using object method funcref at the script level
7514+ lines = << trim END
7515+ vim9script
7516+ class A
7517+ this.val: number
7518+ def Foo (): number
7519+ return this.val
7520+ enddef
7521+ endclass
7522+ var a = A.new (345 )
7523+ var Fn = a .Foo
7524+ assert_equal (345 , Fn ())
7525+ END
7526+ v9.CheckSourceSuccess (lines )
7527+
75137528 # Using object method funcref from another object method
75147529 lines = << trim END
75157530 vim9script
@@ -7604,6 +7619,26 @@ def Test_object_funcref()
76047619 a .Bar ()
76057620 END
76067621 v9.CheckSourceSuccess (lines )
7622+
7623+ # Using object method funcref using call ()
7624+ lines = << trim END
7625+ vim9script
7626+ class A
7627+ this.val: number
7628+ def Foo (): number
7629+ return this.val
7630+ enddef
7631+ endclass
7632+
7633+ def Bar (obj: A)
7634+ assert_equal (123 , call (obj.Foo, []))
7635+ enddef
7636+
7637+ var a = A.new (123 )
7638+ Bar (a )
7639+ assert_equal (123 , call (a .Foo, []))
7640+ END
7641+ v9.CheckSourceSuccess (lines )
76077642enddef
76087643
76097644" Test for using a class method as a funcref
@@ -7637,6 +7672,21 @@ def Test_class_funcref()
76377672 END
76387673 v9.CheckSourceSuccess (lines )
76397674
7675+ # Using class method funcref at the script level
7676+ lines = << trim END
7677+ vim9script
7678+ class A
7679+ public static val: number
7680+ static def Foo (): number
7681+ return val
7682+ enddef
7683+ endclass
7684+ A.val = 567
7685+ var Fn = A.Foo
7686+ assert_equal (567 , Fn ())
7687+ END
7688+ v9.CheckSourceSuccess (lines )
7689+
76407690 # Using function () to get a class method funcref
76417691 lines = << trim END
76427692 vim9script
@@ -7725,6 +7775,25 @@ def Test_class_funcref()
77257775 A.Bar ()
77267776 END
77277777 v9.CheckSourceSuccess (lines )
7778+
7779+ # Using class method funcref using call ()
7780+ lines = << trim END
7781+ vim9script
7782+ class A
7783+ public static val: number
7784+ static def Foo (): number
7785+ return val
7786+ enddef
7787+ endclass
7788+
7789+ def Bar ()
7790+ A.val = 468
7791+ assert_equal (468 , call (A.Foo, []))
7792+ enddef
7793+ Bar ()
7794+ assert_equal (468 , call (A.Foo, []))
7795+ END
7796+ v9.CheckSourceSuccess (lines )
77287797enddef
77297798
77307799" Test for using an object member as a funcref
0 commit comments