From fffed2fc7ef0bb95f05da4397b4e41f70e61d8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Wed, 19 Jun 2024 10:51:04 +0200 Subject: [PATCH] add more tests --- .../ThrownExceptionNotInFunctionTest.scala | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala b/analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala index 24780f6a9..87e92d5b4 100644 --- a/analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala +++ b/analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala @@ -130,12 +130,41 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe | f2(identity)(identity) | f3(identity)(42)(identity) | f4(42, 42, identity) + | + | class A { + | def f1(x1: Int => Int, x2: String => String) = ??? + | def f2(x1: Int => Int)(x2: String => String) = ??? + | def f3(x1: Int => Int)(x2: Int)(x3: String => String) = ??? + | def f4(x1: Int, x2: Int, x3: String => String) = ??? + | } + | final val a = new A + | + | //not ok + | a.f1(throw ex, throw ex) + | a.f1(identity, throw ex) + | a.f1(throw ex, identity) + | + | a.f2(throw ex)(throw ex) + | a.f2(identity)(throw ex) + | a.f2(throw ex)(identity) + | + | a.f3(throw ex)(42)(throw ex) + | a.f3(throw ex)(42)(identity) + | a.f3(identity)(42)(throw ex) + | + | a.f4(42, 42, throw ex) + | + | //ok + | a.f1(identity, identity) + | a.f2(identity)(identity) + | a.f3(identity)(42)(identity) + | a.f4(42, 42, identity) |}""".stripMargin ) } test("Testing constructor invocation") { - assertErrors(1, + assertErrors(7, //language=Scala s""" |object whatever { @@ -144,10 +173,20 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe | class A(f: String => Int) | | new A(throw ex) + | + | class B(f: String => Int)(g: Int => String) + | + | new B(throw ex)(identity) + | new B(identity)(throw ex) + | new B(throw ex)(throw ex) + | + | class C(f: String => Int, g: Int => String) + | + | new C(throw ex, identity) + | new C(identity, throw ex) + | new C(throw ex, throw ex) |} |""".stripMargin ) } - - }