mirror of
https://github.com/vim/vim.git
synced 2025-10-07 05:54:16 -04:00
patch 9.0.1041: cannot define a method in a class
Problem: Cannot define a method in a class. Solution: Implement defining an object method. Make calling an object method work.
This commit is contained in:
@@ -130,12 +130,19 @@ def Test_class_basic()
|
||||
class TextPosition
|
||||
this.lnum: number
|
||||
this.col: number
|
||||
|
||||
def ToString(): string
|
||||
return $'({this.lnum}, {this.col})'
|
||||
enddef
|
||||
endclass
|
||||
|
||||
# use the automatically generated new() method
|
||||
var pos = TextPosition.new(2, 12)
|
||||
assert_equal(2, pos.lnum)
|
||||
assert_equal(12, pos.col)
|
||||
|
||||
# call an object method
|
||||
assert_equal('(2, 12)', pos.ToString())
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
Reference in New Issue
Block a user