@@ -6,6 +6,24 @@ import org.scalatest.funsuite.AnyFunSuite
6
6
final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTest {
7
7
settings.pluginOptions.value ++= List (" AVSystemAnalyzer:-discardedMonixTask" )
8
8
9
+
10
+ test(" Testing simple methods" ) {
11
+ assertErrors(1 ,
12
+ // language=Scala
13
+ """
14
+ |object whatever {
15
+ | def ex: Exception = ???
16
+ |
17
+ | def f0(x1: Int => Int) = ???
18
+ |
19
+ | //not ok
20
+ | f0(throw ex)
21
+ |
22
+ | //ok
23
+ | f0(identity)
24
+ |}""" .stripMargin)
25
+ }
26
+
9
27
Seq (
10
28
(" Option[_]" , " map" ),
11
29
(" Option[_]" , " flatMap" ),
@@ -26,7 +44,7 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
26
44
(" String => Int" , " compose" ),
27
45
(" Seq[_]" , " foreach" ),
28
46
).foreach { case (tpe, function) =>
29
- test(s " Testing $function of $tpe" ) {
47
+ test(s " Testing method $function of $tpe" ) {
30
48
assertErrors(10 ,
31
49
// language=Scala
32
50
s """
@@ -79,4 +97,57 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
79
97
)
80
98
}
81
99
}
100
+
101
+ test(" Testing multiple arguments" ) {
102
+ assertErrors(10 ,
103
+ // language=Scala
104
+ """
105
+ |object whatever {
106
+ | def ex: Exception = ???
107
+ |
108
+ | def f1(x1: Int => Int, x2: String => String) = ???
109
+ | def f2(x1: Int => Int)(x2: String => String) = ???
110
+ | def f3(x1: Int => Int)(x2: Int)(x3: String => String) = ???
111
+ | def f4(x1: Int, x2: Int, x3: String => String) = ???
112
+ |
113
+ | //not ok
114
+ | f1(throw ex, throw ex)
115
+ | f1(identity, throw ex)
116
+ | f1(throw ex, identity)
117
+ |
118
+ | f2(throw ex)(throw ex)
119
+ | f2(identity)(throw ex)
120
+ | f2(throw ex)(identity)
121
+ |
122
+ | f3(throw ex)(42)(throw ex)
123
+ | f3(throw ex)(42)(identity)
124
+ | f3(identity)(42)(throw ex)
125
+ |
126
+ | f4(42, 42, throw ex)
127
+ |
128
+ | //ok
129
+ | f1(identity, identity)
130
+ | f2(identity)(identity)
131
+ | f3(identity)(42)(identity)
132
+ | f4(42, 42, identity)
133
+ |}""" .stripMargin
134
+ )
135
+ }
136
+
137
+ test(" Testing constructor invocation" ) {
138
+ assertErrors(1 ,
139
+ // language=Scala
140
+ s """
141
+ |object whatever {
142
+ | def ex: Exception = ???
143
+ |
144
+ | class A(f: String => Int)
145
+ |
146
+ | new A(throw ex)
147
+ |}
148
+ | """ .stripMargin
149
+ )
150
+ }
151
+
152
+
82
153
}
0 commit comments