Check number of suspensions in crossinline tests
This commit is contained in:
@@ -6,7 +6,11 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val l: suspend () -> Unit = { c() }
|
||||
val l: suspend () -> Unit = {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
|
||||
@@ -18,26 +22,16 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL"
|
||||
StateMachineChecker.check(numberOfSuspensions = 8)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+7
-14
@@ -9,10 +9,13 @@ suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val l: suspend () -> Unit = {
|
||||
val l1 : suspend () -> Unit = {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
l1()
|
||||
l1()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -23,26 +26,16 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL $i"
|
||||
StateMachineChecker.check(numberOfSuspensions = 16)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+8
-14
@@ -8,22 +8,16 @@
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val l: suspend () -> Unit = {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -33,7 +27,7 @@ import COROUTINES_PACKAGE.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
@@ -43,6 +37,6 @@ fun box(): String {
|
||||
res = "FAIL 1"
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL 2"
|
||||
StateMachineChecker.check(numberOfSuspensions = 10)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -20,21 +20,28 @@ suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val sr = object: SuspendRunnable {
|
||||
override suspend fun run() {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -45,26 +52,16 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL $i"
|
||||
StateMachineChecker.check(numberOfSuspensions = 256)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+11
-14
@@ -12,8 +12,10 @@ interface SuspendRunnable {
|
||||
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val l: suspend () -> Unit = {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -24,14 +26,7 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
@@ -45,26 +40,28 @@ fun box(): String {
|
||||
val l : suspend () -> Unit = {
|
||||
val sr = object: SuspendRunnable {
|
||||
override suspend fun run() {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
l()
|
||||
l()
|
||||
}
|
||||
}
|
||||
sr.run()
|
||||
sr.run()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL $i"
|
||||
StateMachineChecker.check(numberOfSuspensions = 256)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val o = object : SuspendRunnable {
|
||||
override suspend fun run() {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
}
|
||||
o.run()
|
||||
o.run()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -26,26 +28,16 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL $i"
|
||||
StateMachineChecker.check(numberOfSuspensions = 8)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+7
-14
@@ -15,12 +15,15 @@ suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val o1 = object: SuspendRunnable {
|
||||
override suspend fun run() {
|
||||
c()
|
||||
c()
|
||||
}
|
||||
}
|
||||
o1.run()
|
||||
o1.run()
|
||||
}
|
||||
}
|
||||
o.run()
|
||||
o.run()
|
||||
}
|
||||
|
||||
// FILE: inlineSite.kt
|
||||
@@ -31,26 +34,16 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL $i"
|
||||
StateMachineChecker.check(numberOfSuspensions = 16)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+8
-11
@@ -14,9 +14,11 @@ suspend inline fun crossinlineMe(crossinline c1: suspend () -> Unit, crossinline
|
||||
val o = object : SuspendRunnable {
|
||||
override suspend fun run1() {
|
||||
c1()
|
||||
c1()
|
||||
}
|
||||
override suspend fun run2() {
|
||||
c2()
|
||||
c2()
|
||||
}
|
||||
}
|
||||
o.run1()
|
||||
@@ -27,19 +29,13 @@ suspend inline fun crossinlineMe(crossinline c1: suspend () -> Unit, crossinline
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var j = 0;
|
||||
|
||||
suspend fun incrementI() {
|
||||
i++
|
||||
}
|
||||
var j = 0
|
||||
|
||||
suspend fun incrementJ() {
|
||||
j++
|
||||
@@ -47,9 +43,10 @@ suspend fun incrementJ() {
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe({ incrementI() }) { incrementJ() }
|
||||
crossinlineMe({ StateMachineChecker.suspendHere() }) { incrementJ() }
|
||||
}
|
||||
if (i != 1) return "FAIL i $i"
|
||||
if (j != 1) return "FAIL i $i"
|
||||
if (j != 0) return "FAIL j != 0 $j"
|
||||
StateMachineChecker.check(numberOfSuspensions = 2)
|
||||
if (j != 2) return "FAIL j != 2 $j"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+7
-14
@@ -8,13 +8,6 @@
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
interface SuspendRunnable {
|
||||
suspend fun run()
|
||||
}
|
||||
@@ -22,11 +15,11 @@ interface SuspendRunnable {
|
||||
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||
val o = object : SuspendRunnable {
|
||||
override suspend fun run() {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
o.run()
|
||||
@@ -39,7 +32,7 @@ import COROUTINES_PACKAGE.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
@@ -49,6 +42,6 @@ fun box(): String {
|
||||
res = "FAIL 1"
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL 2"
|
||||
StateMachineChecker.check(numberOfSuspensions = 5)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -18,26 +18,19 @@ import COROUTINES_PACKAGE.intrinsics.*
|
||||
import helpers.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||
i++
|
||||
COROUTINE_SUSPENDED
|
||||
c.startCoroutine(CheckStateMachineContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
crossinlineMe {
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
StateMachineChecker.suspendHere()
|
||||
}
|
||||
}
|
||||
if (i != 1) return "FAIL"
|
||||
StateMachineChecker.check(numberOfSuspensions = 10)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user