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