[Spec tests] Add spec tests for kotlin.Nothing, kotlin.Unit, reference equality and cast expressions

This commit is contained in:
anastasiia.spaseeva
2019-11-18 18:20:27 +03:00
parent bf50edee17
commit 44d0a99875
31 changed files with 1194 additions and 32 deletions
@@ -0,0 +1,30 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, cast-expression -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: check of the cast operators as or as?
*/
fun box(): String {
val c = Class()
if (c.data !is () -> Nothing) return "NOK"
val e1 : () -> Nothing = c.exception as () -> Nothing as? () -> Nothing ?: return "NOK"
val v = c.value as () -> Nothing as? () -> Nothing ?: return "NOK"
return "OK"
}
open class Class() {
var data: () -> Nothing = { throwException("boo") as Nothing }
var exception: () -> CharSequence = { throwException("foo") as String }
val value: () -> Any
get() = { TODO() as Nothing }
}
private fun throwException(m: String): Any {
throw IllegalArgumentException(m)
}
@@ -0,0 +1,14 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": " check of the cast operators as or as?",
"unexpectedBehaviour": false
}
]
}
}
}