comparison src/testdir/test_vim9_class.vim @ 31639:62237ea155d9 v9.0.1152

patch 9.0.1152: class "implements" argument not implemented Commit: https://github.com/vim/vim/commit/94674f2223aafeaa4690f25e12f3ebe07814c5ba Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 6 18:42:20 2023 +0000 patch 9.0.1152: class "implements" argument not implemented Problem: Class "implements" argument not implemented. Solution: Implement "implements" argument. Add basic checks for when a class implements an interface.
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 Jan 2023 19:45:05 +0100
parents 5c1b7a87466e
children fc259e8db5bf
comparison
equal deleted inserted replaced
31638:75be0502f95c 31639:62237ea155d9
610 endinterface 610 endinterface
611 END 611 END
612 v9.CheckScriptFailure(lines, 'E1345: Not a valid command in an interface: return 5') 612 v9.CheckScriptFailure(lines, 'E1345: Not a valid command in an interface: return 5')
613 enddef 613 enddef
614 614
615 def Test_class_implements_interface()
616 var lines =<< trim END
617 vim9script
618
619 interface Some
620 static count: number
621 def Method(nr: number)
622 endinterface
623
624 class SomeImpl implements Some
625 static count: number
626 def Method(nr: number)
627 echo nr
628 enddef
629 endclass
630 END
631 v9.CheckScriptSuccess(lines)
632
633 lines =<< trim END
634 vim9script
635
636 interface Some
637 static counter: number
638 def Method(nr: number)
639 endinterface
640
641 class SomeImpl implements Some
642 static count: number
643 def Method(nr: number)
644 echo nr
645 enddef
646 endclass
647 END
648 v9.CheckScriptFailure(lines, 'E1348: Member "counter" of interface "Some" not implemented')
649
650 lines =<< trim END
651 vim9script
652
653 interface Some
654 static count: number
655 def Methods(nr: number)
656 endinterface
657
658 class SomeImpl implements Some
659 static count: number
660 def Method(nr: number)
661 echo nr
662 enddef
663 endclass
664 END
665 v9.CheckScriptFailure(lines, 'E1349: Function "Methods" of interface "Some" not implemented')
666 enddef
667
615 668
616 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 669 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker