Update spec testdata according to previous commits

This commit is contained in:
Dmitriy Novozhilov
2019-12-26 15:19:53 +03:00
parent 5dfe100ae5
commit d210df9ea3
10 changed files with 383 additions and 63 deletions
@@ -1,3 +1,4 @@
// !LANGUAGE: +AllowContractsForNonOverridableMembers +AllowReifiedGenericsInContracts
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNREACHABLE_CODE -UNUSED_EXPRESSION
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
@@ -19,16 +20,16 @@ object case_1 {
private const val value_3 = false
fun case_1_1(): Boolean? {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returnsNotNull() implies (value_1) }
contract { returnsNotNull() implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_1<!>) }
return if (value_1) true else null
}
fun case_1_2(): Boolean? {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(null) implies (value_2) }
contract { returns(null) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_2<!>) }
return if (value_2) null else true
}
fun case_1_3(): Boolean {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(true) implies (value_3) }
contract { returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_3<!>) }
return value_3
}
}
@@ -50,22 +51,22 @@ class case_2(value_5: Boolean, val value_1: Boolean) {
}
fun case_2_2(): Boolean? {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(null) implies (value_1) }
contract { returns(null) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_1<!>) }
return if (value_1) null else true
}
fun case_2_3(): Boolean {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(true) implies (value_2) }
contract { returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_2<!>) }
return value_2
}
fun case_2_4(): Boolean {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(false) implies (value_3) }
contract { returns(false) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>value_3<!>) }
return !(value_3)
}
inline fun <reified K : Number> K.case_2_5(): Boolean? {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returnsNotNull() implies (<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>value_4<!>) }
contract { returnsNotNull() implies (<!ERROR_IN_CONTRACT_DESCRIPTION, NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>value_4<!>) }
return if (<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>value_4<!>) true else null
}
}
@@ -1,3 +1,4 @@
// !LANGUAGE: +AllowContractsForNonOverridableMembers +AllowReifiedGenericsInContracts
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
@@ -22,15 +23,3 @@ fun <T : Number, K : <!FINAL_UPPER_BOUND!>String<!>> T?.case_2(value_1: K?) {
contract { returns() implies (this@case_2 is <!ERROR_IN_CONTRACT_DESCRIPTION!>T<!> && value_1 is K) }
if (!(this@case_2 is T && value_1 is K)) throw Exception()
}
// TESTCASE NUMBER: 3
inline fun <reified T : Number> T?.case_3(value_1: Any?) {
contract { returns() implies (value_1 is <!ERROR_IN_CONTRACT_DESCRIPTION!>T<!>) }
if (!(value_1 is T)) throw Exception()
}
// TESTCASE NUMBER: 4
inline fun <reified T : Number, K> K?.case_4(value_1: Any?) {
contract { returns() implies (this@case_4 !is <!ERROR_IN_CONTRACT_DESCRIPTION!>T<!> || value_1 is T) }
if (!(this@case_4 !is T || value_1 is T)) throw Exception()
}
@@ -2,5 +2,3 @@ package
public fun </*0*/ T : kotlin.Number?> T.case_1(): kotlin.Unit
public fun </*0*/ T : kotlin.Number, /*1*/ K : kotlin.String> T?.case_2(/*0*/ value_1: K?): kotlin.Unit
public inline fun </*0*/ reified T : kotlin.Number> T?.case_3(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public inline fun </*0*/ reified T : kotlin.Number, /*1*/ K> K?.case_4(/*0*/ value_1: kotlin.Any?): kotlin.Unit
@@ -0,0 +1,24 @@
// !LANGUAGE: +AllowContractsForNonOverridableMembers +AllowReifiedGenericsInContracts
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
* KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
*
* SECTIONS: contracts, declarations, contractBuilder, effects, returns
* NUMBER: 4
* DESCRIPTION: Returns effect with type checking with generic parameter
*/
import kotlin.contracts.*
// TESTCASE NUMBER: 1
inline fun <reified T : Number> T?.case_1(value_1: Any?) {
contract { returns() implies (value_1 is T) }
if (!(value_1 is T)) throw Exception()
}
// TESTCASE NUMBER: 2
inline fun <reified T : Number, K> K?.case_2(value_1: Any?) {
contract { returns() implies (this@case_2 !is T || value_1 is T) }
if (!(this@case_2 !is T || value_1 is T)) throw Exception()
}
@@ -0,0 +1,8 @@
package
public inline fun </*0*/ reified T : kotlin.Number> T?.case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 is T
public inline fun </*0*/ reified T : kotlin.Number, /*1*/ K> K?.case_2(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> <this> !is T || value_1 is T