Skip to content

Commit fffed2f

Browse files
committed
add more tests
1 parent e259d63 commit fffed2f

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala

+42-3
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,41 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
130130
| f2(identity)(identity)
131131
| f3(identity)(42)(identity)
132132
| f4(42, 42, identity)
133+
|
134+
| class A {
135+
| def f1(x1: Int => Int, x2: String => String) = ???
136+
| def f2(x1: Int => Int)(x2: String => String) = ???
137+
| def f3(x1: Int => Int)(x2: Int)(x3: String => String) = ???
138+
| def f4(x1: Int, x2: Int, x3: String => String) = ???
139+
| }
140+
| final val a = new A
141+
|
142+
| //not ok
143+
| a.f1(throw ex, throw ex)
144+
| a.f1(identity, throw ex)
145+
| a.f1(throw ex, identity)
146+
|
147+
| a.f2(throw ex)(throw ex)
148+
| a.f2(identity)(throw ex)
149+
| a.f2(throw ex)(identity)
150+
|
151+
| a.f3(throw ex)(42)(throw ex)
152+
| a.f3(throw ex)(42)(identity)
153+
| a.f3(identity)(42)(throw ex)
154+
|
155+
| a.f4(42, 42, throw ex)
156+
|
157+
| //ok
158+
| a.f1(identity, identity)
159+
| a.f2(identity)(identity)
160+
| a.f3(identity)(42)(identity)
161+
| a.f4(42, 42, identity)
133162
|}""".stripMargin
134163
)
135164
}
136165

137166
test("Testing constructor invocation") {
138-
assertErrors(1,
167+
assertErrors(7,
139168
//language=Scala
140169
s"""
141170
|object whatever {
@@ -144,10 +173,20 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
144173
| class A(f: String => Int)
145174
|
146175
| new A(throw ex)
176+
|
177+
| class B(f: String => Int)(g: Int => String)
178+
|
179+
| new B(throw ex)(identity)
180+
| new B(identity)(throw ex)
181+
| new B(throw ex)(throw ex)
182+
|
183+
| class C(f: String => Int, g: Int => String)
184+
|
185+
| new C(throw ex, identity)
186+
| new C(identity, throw ex)
187+
| new C(throw ex, throw ex)
147188
|}
148189
|""".stripMargin
149190
)
150191
}
151-
152-
153192
}

0 commit comments

Comments
 (0)