Add tests for exceptions from evaluate expression
This commit is contained in:
@@ -100,7 +100,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
|||||||
val virtualMachine = context.getDebugProcess().getVirtualMachineProxy().getVirtualMachine()
|
val virtualMachine = context.getDebugProcess().getVirtualMachineProxy().getVirtualMachine()
|
||||||
|
|
||||||
// If bytecode was taken from cache and exception was thrown - recompile bytecode and run eval4j again
|
// If bytecode was taken from cache and exception was thrown - recompile bytecode and run eval4j again
|
||||||
if (result is ExceptionThrown && isCompiledDataFromCache) {
|
if (isCompiledDataFromCache && result is ExceptionThrown && result.kind == ExceptionThrown.ExceptionKind.BROKEN_CODE) {
|
||||||
return runEval4j(context, extractAndCompile(codeFragment, sourcePosition), args).toJdiValue(virtualMachine)
|
return runEval4j(context, extractAndCompile(codeFragment, sourcePosition), args).toJdiValue(virtualMachine)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ LineBreakpoint created at clearCache.kt:86
|
|||||||
LineBreakpoint created at clearCache.kt:95
|
LineBreakpoint created at clearCache.kt:95
|
||||||
LineBreakpoint created at clearCache.kt:105
|
LineBreakpoint created at clearCache.kt:105
|
||||||
LineBreakpoint created at clearCache.kt:113
|
LineBreakpoint created at clearCache.kt:113
|
||||||
LineBreakpoint created at clearCache.kt:124
|
LineBreakpoint created at clearCache.kt:123
|
||||||
LineBreakpoint created at clearCache.kt:133
|
LineBreakpoint created at clearCache.kt:131
|
||||||
LineBreakpoint created at clearCache.kt:143
|
LineBreakpoint created at clearCache.kt:149
|
||||||
LineBreakpoint created at clearCache.kt:151
|
LineBreakpoint created at clearCache.kt:154
|
||||||
|
LineBreakpoint created at clearCache.kt:161
|
||||||
LineBreakpoint created at clearCache.kt:169
|
LineBreakpoint created at clearCache.kt:169
|
||||||
LineBreakpoint created at clearCache.kt:174
|
|
||||||
LineBreakpoint created at clearCache.kt:181
|
|
||||||
LineBreakpoint created at clearCache.kt:189
|
|
||||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!RT_JAR! clearCache.ClearCachePackage
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!RT_JAR! clearCache.ClearCachePackage
|
||||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
clearCache.kt:11
|
clearCache.kt:11
|
||||||
@@ -39,18 +37,15 @@ clearCache.kt:94
|
|||||||
clearCache.kt:104
|
clearCache.kt:104
|
||||||
clearCache.kt:112
|
clearCache.kt:112
|
||||||
Compile bytecode for c.size()
|
Compile bytecode for c.size()
|
||||||
clearCache.kt:123
|
clearCache.kt:122
|
||||||
Compile bytecode for c.get(0)
|
|
||||||
clearCache.kt:132
|
|
||||||
clearCache.kt:142
|
|
||||||
Compile bytecode for o.test()
|
Compile bytecode for o.test()
|
||||||
clearCache.kt:150
|
clearCache.kt:130
|
||||||
clearCache.kt:168
|
clearCache.kt:148
|
||||||
Compile bytecode for obj.test()
|
Compile bytecode for obj.test()
|
||||||
clearCache.kt:173
|
clearCache.kt:153
|
||||||
clearCache.kt:180
|
clearCache.kt:160
|
||||||
Compile bytecode for o.test()
|
Compile bytecode for o.test()
|
||||||
clearCache.kt:188
|
clearCache.kt:168
|
||||||
Compile bytecode for o.test()
|
Compile bytecode for o.test()
|
||||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
LineBreakpoint created at exceptions.kt:9
|
||||||
|
LineBreakpoint created at exceptions.kt:14
|
||||||
|
LineBreakpoint created at exceptions.kt:26
|
||||||
|
LineBreakpoint created at exceptions.kt:31
|
||||||
|
LineBreakpoint created at exceptions.kt:42
|
||||||
|
LineBreakpoint created at exceptions.kt:51
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!RT_JAR! exceptions.ExceptionsPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
exceptions.kt:8
|
||||||
|
Compile bytecode for fail()
|
||||||
|
exceptions.kt:13
|
||||||
|
exceptions.kt:25
|
||||||
|
Compile bytecode for o as Derived
|
||||||
|
exceptions.kt:30
|
||||||
|
exceptions.kt:41
|
||||||
|
Compile bytecode for c.get(0)
|
||||||
|
exceptions.kt:50
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -114,26 +114,6 @@ fun subTypePlatform() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun genericRerun() {
|
|
||||||
if (true) {
|
|
||||||
val c = ArrayList<Int>()
|
|
||||||
c.add(1)
|
|
||||||
// EXPRESSION: c.get(0)
|
|
||||||
// RESULT: 1: I
|
|
||||||
//Breakpoint!
|
|
||||||
val b = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
val c = ArrayList<String>()
|
|
||||||
c.add("a")
|
|
||||||
// EXPRESSION: c.get(0)
|
|
||||||
// RESULT: "a": Ljava/lang/String;
|
|
||||||
//Breakpoint!
|
|
||||||
val b = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun innerClass() {
|
fun innerClass() {
|
||||||
if (true) {
|
if (true) {
|
||||||
val o = TestInnerClasses.Base()
|
val o = TestInnerClasses.Base()
|
||||||
@@ -200,7 +180,6 @@ fun main(args: Array<String>) {
|
|||||||
primitiveTypes()
|
primitiveTypes()
|
||||||
subType()
|
subType()
|
||||||
subTypePlatform()
|
subTypePlatform()
|
||||||
genericRerun()
|
|
||||||
innerClass()
|
innerClass()
|
||||||
objects()
|
objects()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package exceptions
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
fun throwException() {
|
||||||
|
// EXPRESSION: fail()
|
||||||
|
// RESULT: instance of java.lang.UnsupportedOperationException(id=ID): Ljava/lang/UnsupportedOperationException;
|
||||||
|
//Breakpoint!
|
||||||
|
val a = 1
|
||||||
|
|
||||||
|
// EXPRESSION: fail()
|
||||||
|
// RESULT: instance of java.lang.UnsupportedOperationException(id=ID): Ljava/lang/UnsupportedOperationException;
|
||||||
|
//Breakpoint!
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fail() {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun classCast() {
|
||||||
|
val o = Base()
|
||||||
|
// EXPRESSION: o as Derived
|
||||||
|
// RESULT: java.lang.ClassCastException: exceptions.Base cannot be cast to exceptions.Derived: Ljava/lang/ClassCastException;
|
||||||
|
//Breakpoint!
|
||||||
|
val a = 1
|
||||||
|
|
||||||
|
// EXPRESSION: o as Derived
|
||||||
|
// RESULT: java.lang.ClassCastException: exceptions.Base cannot be cast to exceptions.Derived: Ljava/lang/ClassCastException;
|
||||||
|
//Breakpoint!
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun genericClassCast() {
|
||||||
|
if (true) {
|
||||||
|
val c = ArrayList<Int>()
|
||||||
|
c.add(1)
|
||||||
|
// EXPRESSION: c.get(0)
|
||||||
|
// RESULT: 1: I
|
||||||
|
//Breakpoint!
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
val c = ArrayList<String>()
|
||||||
|
c.add("a")
|
||||||
|
// EXPRESSION: c.get(0)
|
||||||
|
// RESULT: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number: Ljava/lang/ClassCastException;
|
||||||
|
//Breakpoint!
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
private fun test(): Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived: Base()
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
throwException()
|
||||||
|
classCast()
|
||||||
|
genericClassCast()
|
||||||
|
}
|
||||||
+5
@@ -151,6 +151,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
doMultipleBreakpointsTest("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/clearCache.kt");
|
doMultipleBreakpointsTest("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/clearCache.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("exceptions.kt")
|
||||||
|
public void testExceptions() throws Exception {
|
||||||
|
doMultipleBreakpointsTest("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|||||||
Reference in New Issue
Block a user