[Spec tests] Add tests for type-checking-expression

This commit is contained in:
anastasiia.spaseeva
2019-12-20 16:37:14 +03:00
parent 2a1e084f03
commit 4a94ffa5dd
8 changed files with 234 additions and 0 deletions
@@ -0,0 +1 @@
java.lang.IllegalStateException: CANNOT_CHECK_FOR_ERASED: Cannot check for instance of erased type: A<Long> (16,18) in /2.1.kt
@@ -0,0 +1,19 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, type-checking-and-containment-checking-expressions, type-checking-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: E is T: The type T must be runtime-available, otherwise it is a compiler error
* EXCEPTION: compiletime
*/
fun box() {
val x = A(1)
val y = x is A<Long>
}
class A<T>(val a: T)
@@ -0,0 +1,20 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, type-checking-and-containment-checking-expressions, type-checking-expression -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: the expression null is T? for any type T always evaluates to true
*/
fun box(): String {
val x = null
if (x is Any? && x is Nothing? && x is String? && x is A?)
if (!((x !is Any?) || (x !is Nothing?) || (x !is String?) || (x !is A?)))
return "OK"
return "NOK"
}
class A()
@@ -1,5 +1,15 @@
{
"1": {
"neg": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "E is T: The type T must be runtime-available, otherwise it is a compiler error",
"unexpectedBehaviour": false
}
]
},
"pos": {
"3": [
{
@@ -16,5 +26,17 @@
}
]
}
},
"4": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "the expression null is T? for any type T always evaluates to true",
"unexpectedBehaviour": false
}
]
}
}
}