Effects: add test on (de)serialization of contracts

- Add ContractDescriptorRenderer
- Add option to dump function contracts in DescriptorRendererOptions
- Add parsing of LANGUAGE_VERSION directive in AbstractLoadJava
- Add tests on serialization-deserializaton identity of contracts

==========
Introduction of EffectSystem: 13/18
This commit is contained in:
Dmitry Savvinov
2017-10-03 15:02:46 +03:00
parent 75ad20f823
commit d20c770a25
29 changed files with 699 additions and 19 deletions
@@ -0,0 +1,44 @@
// LANGUAGE_VERSION: 1.3
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package test
import kotlin.internal.contracts.*
fun twoReturnsValue(b: Boolean) {
contract {
returns(true) implies b
returns(false) implies (!b)
}
}
fun threeReturnsValue(b: Boolean) {
contract {
returnsNotNull() implies (b != null)
returns(true) implies (b)
returns(false) implies (!b)
}
}
fun returnsAndFinished(b: Boolean) {
contract {
returns(true) implies (b)
returns() implies (b != null)
returns(false) implies (!b)
}
}
fun returnsAndCalls(b: Boolean, block: () -> Unit) {
contract {
returns(false) implies (!b)
callsInPlace(block)
returns(true) implies (b)
}
}
fun severalCalls(x: () -> Unit, y: () -> Unit) {
contract {
callsInPlace(x, InvocationKind.AT_MOST_ONCE)
callsInPlace(y, InvocationKind.AT_LEAST_ONCE)
}
}