@@ -1223,20 +1223,22 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1223
1223
}
1224
1224
1225
1225
if (containsFailureExecution(testSet)) {
1226
+ val expectedErrorVariable = currentMethodParameters[CgParameterKind .ExpectedException ]
1227
+ ? : error(" Test set $testSet contains failure execution, but test method signature has no error parameter" )
1226
1228
currentTryBlock =
1227
1229
if (containsReflectiveCall) {
1228
- currentTryBlock.catch (InvocationTargetException ::class .java.id) { exception ->
1229
- testFrameworkManager.assertBoolean(
1230
- CgIsInstance (expectedErrorVariable, exception[getTargetException]())
1231
- )
1232
- }
1233
- } else {
1234
- currentTryBlock.catch (Throwable ::class .java.id) { throwable ->
1235
- testFrameworkManager.assertBoolean(
1236
- CgIsInstance (expectedErrorVariable, throwable)
1237
- )
1230
+ currentTryBlock.catch (InvocationTargetException ::class .java.id) { exception ->
1231
+ testFrameworkManager.assertBoolean(
1232
+ CgIsInstance (expectedErrorVariable, exception[getTargetException]())
1233
+ )
1234
+ }
1235
+ } else {
1236
+ currentTryBlock.catch (Throwable ::class .java.id) { throwable ->
1237
+ testFrameworkManager.assertBoolean(
1238
+ CgIsInstance (expectedErrorVariable, throwable)
1239
+ )
1240
+ }
1238
1241
}
1239
- }
1240
1242
}
1241
1243
1242
1244
if (statics.isNotEmpty()) {
@@ -1333,19 +1335,20 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1333
1335
val containsFailureExecution = containsFailureExecution(testSet)
1334
1336
if (containsFailureExecution) {
1335
1337
val classClassId = Class ::class .id
1336
- expectedErrorVariable = declareParameter(
1337
- type = BuiltinClassId (
1338
- name = classClassId.name,
1339
- simpleName = classClassId.simpleName,
1340
- canonicalName = classClassId.canonicalName,
1341
- packageName = classClassId.packageName,
1342
- typeParameters = TypeParameters (listOf (Throwable ::class .java.id))
1338
+ val expectedException = CgParameterDeclaration (
1339
+ parameter = declareParameter(
1340
+ type = BuiltinClassId (
1341
+ name = classClassId.name,
1342
+ simpleName = classClassId.simpleName,
1343
+ canonicalName = classClassId.canonicalName,
1344
+ packageName = classClassId.packageName,
1345
+ typeParameters = TypeParameters (listOf (Throwable ::class .java.id))
1346
+ ),
1347
+ name = nameGenerator.variableName(expectedErrorVarName)
1343
1348
),
1344
- name = nameGenerator.variableName(expectedErrorVarName)
1349
+ // exceptions are always reference type
1350
+ isReferenceType = true ,
1345
1351
)
1346
-
1347
- // exceptions are always reference type
1348
- val expectedException = CgParameterDeclaration (parameter = expectedErrorVariable, isReferenceType = true )
1349
1352
this + = expectedException
1350
1353
currentMethodParameters[CgParameterKind .ExpectedException ] = expectedException.parameter
1351
1354
}
0 commit comments