[Spec tests] Add tests for kotlin.Nothing and kotlin.Unit built-in types

This commit is contained in:
anastasiia.spaseeva
2019-11-18 18:20:27 +03:00
parent 52ac8d788d
commit bf50edee17
16 changed files with 727 additions and 50 deletions
@@ -0,0 +1,23 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, built-in-types-and-their-semantics, kotlin.nothing-1 -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: todo
*/
fun foo(): Nothing {
throw Exception()
}
fun box() {
try {
foo()
} catch (e: Exception) {
return "OK"
}
return "NOK"
}
@@ -0,0 +1,14 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": "todo",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,31 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: todo
*/
fun foo1() {
return Unit
}
fun foo2(): Unit {
return Unit
}
fun foo3(): Unit {
}
fun box(){
val u1 = foo1()
val u2 = foo2()
val u3 = foo3()
if (u1 === u2 && u1 === u3 && u2 === u3) {
return ( "OK")
}
return ( "NOK")
}
@@ -0,0 +1,14 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": "todo",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,21 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* PLACE: type-system, type-kinds, built-in-types, kotlin.nothing -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: todo
*/
fun box() {
val b : Any? = null
try {
val a: Int
a = b!!
} catch (e: NullPointerException) {
return "OK"
}
return "NOK"
}
@@ -0,0 +1,26 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* PLACE: type-system, type-kinds, built-in-types, kotlin.nothing -> paragraph 1 -> sentence 1
* NUMBER: 2
* DESCRIPTION: todo
*/
fun foo(s: String?): String {
val data = s ?: throw IllegalArgumentException("not null string is expected");
}
fun box() {
val result = "NOK"
val b = foo("")
try {
val a = foo(null)
} catch (e: IllegalArgumentException) {
result = "OK"
}
return result
}
@@ -0,0 +1,20 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": "todo",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": "todo",
"unexpectedBehaviour": false
}
]
}
}
}