Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
31753:048ae7b3fdd6 | 31754:48431422f766 |
---|---|
868 echo nr | 868 echo nr |
869 enddef | 869 enddef |
870 endclass | 870 endclass |
871 END | 871 END |
872 v9.CheckScriptFailure(lines, 'E1349: Function "Methods" of interface "Some" not implemented') | 872 v9.CheckScriptFailure(lines, 'E1349: Function "Methods" of interface "Some" not implemented') |
873 | |
874 # Check different order of members in class and interface works. | |
875 lines =<< trim END | |
876 vim9script | |
877 | |
878 interface Result | |
879 this.label: string | |
880 this.errpos: number | |
881 endinterface | |
882 | |
883 # order of members is opposite of interface | |
884 class Failure implements Result | |
885 this.errpos: number = 42 | |
886 this.label: string = 'label' | |
887 endclass | |
888 | |
889 def Test() | |
890 var result: Result = Failure.new() | |
891 | |
892 assert_equal('label', result.label) | |
893 assert_equal(42, result.errpos) | |
894 enddef | |
895 | |
896 Test() | |
897 END | |
898 v9.CheckScriptSuccess(lines) | |
873 enddef | 899 enddef |
874 | 900 |
875 def Test_class_used_as_type() | 901 def Test_class_used_as_type() |
876 var lines =<< trim END | 902 var lines =<< trim END |
877 vim9script | 903 vim9script |