Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halotukozak committed Jun 19, 2024
1 parent e259d63 commit fffed2f
Showing 1 changed file with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
)
}


}

0 comments on commit fffed2f

Please sign in to comment.