From 3b48691d83057c1900623bf30da23277fa2c986c Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 6 Dec 2024 09:26:30 +0300 Subject: [PATCH] Adding more tests --- tests/test_any.cs | 40 ++++++++++++++++++++++++++++++++++++++++ tests/test_shared.cs | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/tests/test_any.cs b/tests/test_any.cs index 1627f41b..51492005 100644 --- a/tests/test_any.cs +++ b/tests/test_any.cs @@ -287,6 +287,26 @@ func int test() Assert.Equal(1111, num); CommonChecks(vm); } + + [Fact] + public void TestNeedExplicitCastForAnyArray() + { + string bhl = @" + + func int test() + { + []int cs + []any anys + + cs = anys + + } + "; + + AssertError(() => MakeVM(bhl), + "incompatible types: '[]int' and '[]any'" + ); + } [Fact] public void TestCastUserTypeMapToAnyMap() @@ -344,4 +364,24 @@ func int test() Assert.Equal(10 + 1111, num); CommonChecks(vm); } + + [Fact] + public void TestNeedExplicitCastForAnyMap() + { + string bhl = @" + + func int test() + { + [string]int cs + [any]any anys + + cs = anys + + } + "; + + AssertError(() => MakeVM(bhl), + "incompatible types: '[string]int' and '[any]any'" + ); + } } diff --git a/tests/test_shared.cs b/tests/test_shared.cs index 92e00310..3a803f0d 100644 --- a/tests/test_shared.cs +++ b/tests/test_shared.cs @@ -811,6 +811,11 @@ public static void AssertEqual(string a, string b) Assert.Equal(a, b); } + public void AssertError(Action action, string msg, PlaceAssert place_assert = null) + { + AssertError(action, msg, place_assert); + } + public void AssertError(Action action, string msg, PlaceAssert place_assert = null) where T : Exception { Exception err = null;