[Spec tests] Add spec tests for kotlin.Nothing, kotlin.Unit, reference equality and cast expressions
This commit is contained in:
+30
@@ -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)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"1": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-213",
|
||||
"casesNumber": 0,
|
||||
"description": " check of the cast operators as or as?",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user