Add tests for exceptions from evaluate expression

This commit is contained in:
Natalia Ukhorskaya
2014-06-23 17:39:53 +04:00
parent 1687b9cbca
commit a17bcce682
6 changed files with 102 additions and 38 deletions
@@ -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() {
if (true) {
val o = TestInnerClasses.Base()
@@ -200,7 +180,6 @@ fun main(args: Array<String>) {
primitiveTypes()
subType()
subTypePlatform()
genericRerun()
innerClass()
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()
}