Mercurial > vim
comparison src/testdir/test_vim9_class.vim @ 32822:b3a42579bb3f v9.0.1724
patch 9.0.1724: vim9class constructor argument type checking bug
Commit: https://github.com/vim/vim/commit/2261c89a49ff2115e1ccc9ab9211e9f0d5a37578
Author: h-east <h.east.727@gmail.com>
Date: Wed Aug 16 21:49:54 2023 +0900
patch 9.0.1724: vim9class constructor argument type checking bug
Problem: vim9class constructor argument type checking bug
Solution: fix it
closes: #12816
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: h-east <h.east.727@gmail.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2023 22:45:03 +0200 |
parents | 57282f1d9e0f |
children | 5fd9fe58c791 |
comparison
equal
deleted
inserted
replaced
32821:52a61f786e78 | 32822:b3a42579bb3f |
---|---|
516 var missing = Person.new() | 516 var missing = Person.new() |
517 END | 517 END |
518 v9.CheckScriptFailure(lines, 'E119:') | 518 v9.CheckScriptFailure(lines, 'E119:') |
519 enddef | 519 enddef |
520 | 520 |
521 | |
522 def Test_class_new_with_object_member() | |
523 var lines =<< trim END | |
524 vim9script | |
525 | |
526 class C | |
527 this.str: string | |
528 this.num: number | |
529 def new(this.str, this.num) | |
530 enddef | |
531 def newVals(this.str, this.num) | |
532 enddef | |
533 endclass | |
534 | |
535 def Check() | |
536 try | |
537 var c = C.new('cats', 2) | |
538 assert_equal('cats', c.str) | |
539 assert_equal(2, c.num) | |
540 | |
541 c = C.newVals('dogs', 4) | |
542 assert_equal('dogs', c.str) | |
543 assert_equal(4, c.num) | |
544 catch | |
545 assert_report($'Unexpected exception was caught: {v:exception}') | |
546 endtry | |
547 enddef | |
548 | |
549 Check() | |
550 END | |
551 v9.CheckScriptSuccess(lines) | |
552 | |
553 lines =<< trim END | |
554 vim9script | |
555 | |
556 class C | |
557 this.str: string | |
558 this.num: number | |
559 def new(this.str, this.num) | |
560 enddef | |
561 endclass | |
562 | |
563 def Check() | |
564 try | |
565 var c = C.new(1, 2) | |
566 catch | |
567 assert_report($'Unexpected exception was caught: {v:exception}') | |
568 endtry | |
569 enddef | |
570 | |
571 Check() | |
572 END | |
573 v9.CheckScriptFailure(lines, 'E1013:') | |
574 | |
575 lines =<< trim END | |
576 vim9script | |
577 | |
578 class C | |
579 this.str: string | |
580 this.num: number | |
581 def newVals(this.str, this.num) | |
582 enddef | |
583 endclass | |
584 | |
585 def Check() | |
586 try | |
587 var c = C.newVals('dogs', 'apes') | |
588 catch | |
589 assert_report($'Unexpected exception was caught: {v:exception}') | |
590 endtry | |
591 enddef | |
592 | |
593 Check() | |
594 END | |
595 v9.CheckScriptFailure(lines, 'E1013:') | |
596 enddef | |
597 | |
521 def Test_class_object_member_inits() | 598 def Test_class_object_member_inits() |
522 var lines =<< trim END | 599 var lines =<< trim END |
523 vim9script | 600 vim9script |
524 class TextPosition | 601 class TextPosition |
525 this.lnum: number | 602 this.lnum: number |