Mercurial > vim
diff src/testdir/test_vim9_class.vim @ 31754:48431422f766 v9.0.1209
patch 9.0.1209: getting interface member does not always work
Commit: https://github.com/vim/vim/commit/29ac5df37baf7e6e751c7ebd4ab37a2aa826e9e6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 16 19:43:47 2023 +0000
patch 9.0.1209: getting interface member does not always work
Problem: Getting interface member does not always work.
Solution: Convert the index on the interface to the index on the object.
(closes #11825)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Jan 2023 20:45:04 +0100 |
parents | 13cecb002fe6 |
children | 85f93e094810 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -870,6 +870,32 @@ def Test_class_implements_interface() endclass END v9.CheckScriptFailure(lines, 'E1349: Function "Methods" of interface "Some" not implemented') + + # Check different order of members in class and interface works. + lines =<< trim END + vim9script + + interface Result + this.label: string + this.errpos: number + endinterface + + # order of members is opposite of interface + class Failure implements Result + this.errpos: number = 42 + this.label: string = 'label' + endclass + + def Test() + var result: Result = Failure.new() + + assert_equal('label', result.label) + assert_equal(42, result.errpos) + enddef + + Test() + END + v9.CheckScriptSuccess(lines) enddef def Test_class_used_as_type()