diff options
author | Ernie Rael <errael@raelity.com> | 2023-12-12 16:58:00 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-12-12 16:58:00 +0100 |
commit | 2025af165ec68d831f0f0f668a3ceac3f39142ef (patch) | |
tree | beb22176d7d2fa61be4054de5a5830cb31b933eb /src/testdir/test_vim9_class.vim | |
parent | c1c3b83816c8e22c9a710fb0c0cebc180ee6ce1e (diff) |
patch 9.0.2160: instanceof() should use varargs as second argv9.0.2160
Problem: instanceof() should use varargs as second arg
Solution: Modify `instanceof()` to use varargs instead of list
Modify `instanceof()` to use varargs instead of list
Valid `instanceof()` arguments are `type`s. A `type` is not a value;
it cannot be added to a list.
This change is non-compatible with the current usage of instanceof;
but instanceof is relatively new and it's a trivial change.
fixes: #13421
closes: #13644
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_vim9_class.vim')
-rw-r--r-- | src/testdir/test_vim9_class.vim | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index 84ea1cb357..e0f5db6253 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -3328,6 +3328,11 @@ def Test_instanceof() class Base3 extends Mix1 endclass + type AliasBase1 = Base1 + type AliasBase2 = Base2 + type AliasIntf1 = Intf1 + type AliasMix1 = Mix1 + var b1 = Base1.new() var b2 = Base2.new() var b3 = Base3.new() @@ -3336,8 +3341,13 @@ def Test_instanceof() assert_true(instanceof(b2, Base1)) assert_false(instanceof(b1, Base2)) assert_true(instanceof(b3, Mix1)) - assert_false(instanceof(b3, [])) - assert_true(instanceof(b3, [Base1, Base2, Intf1])) + assert_true(instanceof(b3, Base1, Base2, Intf1)) + + assert_true(instanceof(b1, AliasBase1)) + assert_true(instanceof(b2, AliasBase1)) + assert_false(instanceof(b1, AliasBase2)) + assert_true(instanceof(b3, AliasMix1)) + assert_true(instanceof(b3, AliasBase1, AliasBase2, AliasIntf1)) def Foo() var a1 = Base1.new() @@ -3348,8 +3358,13 @@ def Test_instanceof() assert_true(instanceof(a2, Base1)) assert_false(instanceof(a1, Base2)) assert_true(instanceof(a3, Mix1)) - assert_false(instanceof(a3, [])) - assert_true(instanceof(a3, [Base1, Base2, Intf1])) + assert_true(instanceof(a3, Base1, Base2, Intf1)) + + assert_true(instanceof(a1, AliasBase1)) + assert_true(instanceof(a2, AliasBase1)) + assert_false(instanceof(a1, AliasBase2)) + assert_true(instanceof(a3, AliasMix1)) + assert_true(instanceof(a3, AliasBase1, AliasBase2, AliasIntf1)) enddef Foo() @@ -3358,6 +3373,58 @@ def Test_instanceof() END v9.CheckSourceSuccess(lines) + + lines =<< trim END + vim9script + + class Base1 + endclass + instanceof(Base1.new()) + END + v9.CheckSourceFailure(lines, 'E119: Not enough arguments for function: instanceof') + + lines =<< trim END + vim9script + + class Base1 + endclass + def F() + instanceof(Base1.new()) + enddef + F() + END + v9.CheckSourceFailure(lines, 'E119: Not enough arguments for function: instanceof') + + lines =<< trim END + vim9script + + class Base1 + endclass + + class Base2 + endclass + + var o = Base2.new() + instanceof(o, Base1, Base2, 3) + END + v9.CheckSourceFailure(lines, 'E693: Class or class typealias required for argument 4', 10) + + lines =<< trim END + vim9script + + class Base1 + endclass + + class Base2 + endclass + + def F() + var o = Base2.new() + instanceof(o, Base1, Base2, 3) + enddef + F() + END + v9.CheckSourceFailure(lines, 'E693: Class or class typealias required for argument 4') enddef " Test for calling a method in the parent class that is extended partially. |