Skip to content

Commit 18a5227

Browse files
committed
Simpler test
1 parent a9d2706 commit 18a5227

File tree

3 files changed

+25
-84
lines changed

3 files changed

+25
-84
lines changed

tests/run/contextual-closure-unwrapping.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/run/contextual-closure-unwrapping.scala

Lines changed: 0 additions & 83 deletions
This file was deleted.

tests/run/i10889.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import scala.annotation.tailrec
2+
import scala.util.chaining.given
3+
4+
object Test {
5+
class Ctx
6+
type Op[A] = Ctx ?=> A
7+
8+
var min = Int.MaxValue
9+
var max = 0
10+
def stk = new Throwable().getStackTrace.length
11+
12+
@tailrec def f[A](n: Int)(op: Op[A]): A =
13+
val depth = stk
14+
min = min.min(depth)
15+
max = max.max(depth)
16+
given Ctx = Ctx()
17+
if (n > 0) f(n-1)(op)
18+
else op
19+
20+
def g(ctx: Ctx) = stk
21+
22+
def main(args: Array[String]): Unit =
23+
val extra = 3
24+
f(10)(Ctx ?=> g(summon[Ctx])).tap(res => assert(res <= max + extra, s"min $min, max $max, ran g at $res"))
25+
}

0 commit comments

Comments
 (0)