comparison src/testdir/test_vim9_class.vim @ 31694:2f61e308b997 v9.0.1179

patch 9.0.1179: not all errors around inheritance are tested Commit: https://github.com/vim/vim/commit/6aa0937fb88001a5ea18e732aad4c625e9b2baeb Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 11 17:59:38 2023 +0000 patch 9.0.1179: not all errors around inheritance are tested Problem: Not all errors around inheritance are tested. Solution: Add more tests. Fix uncovered problems.
author Bram Moolenaar <Bram@vim.org>
date Wed, 11 Jan 2023 19:00:06 +0100
parents 2f1af1b2f82d
children 9fba3e8bbadc
comparison
equal deleted inserted replaced
31693:2698d61dcc97 31694:2f61e308b997
836 836
837 var o = Child.new('John', 42) 837 var o = Child.new('John', 42)
838 assert_equal('John: 42', o.ToString()) 838 assert_equal('John: 42', o.ToString())
839 END 839 END
840 v9.CheckScriptSuccess(lines) 840 v9.CheckScriptSuccess(lines)
841
842 lines =<< trim END
843 vim9script
844 class Child
845 this.age: number
846 def ToString(): number
847 return this.age
848 enddef
849 def ToString(): string
850 return this.age
851 enddef
852 endclass
853 END
854 v9.CheckScriptFailure(lines, 'E1355: Duplicate function: ToString')
855
856 lines =<< trim END
857 vim9script
858 class Child
859 this.age: number
860 def ToString(): string
861 return super .ToString() .. ': ' .. this.age
862 enddef
863 endclass
864 var o = Child.new(42)
865 echo o.ToString()
866 END
867 v9.CheckScriptFailure(lines, 'E1356:')
868
869 lines =<< trim END
870 vim9script
871 class Base
872 this.name: string
873 def ToString(): string
874 return this.name
875 enddef
876 endclass
877
878 var age = 42
879 def ToString(): string
880 return super.ToString() .. ': ' .. age
881 enddef
882 echo ToString()
883 END
884 v9.CheckScriptFailure(lines, 'E1357:')
885
886 lines =<< trim END
887 vim9script
888 class Child
889 this.age: number
890 def ToString(): string
891 return super.ToString() .. ': ' .. this.age
892 enddef
893 endclass
894 var o = Child.new(42)
895 echo o.ToString()
896 END
897 v9.CheckScriptFailure(lines, 'E1358:')
841 enddef 898 enddef
842 899
843 900
844 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 901 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker