Skip to content

Commit 0c99e79

Browse files
committed
CPS: test case for ticket 1684
1 parent ded6e2d commit 0c99e79

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
d = 1, d2 = 1.0, pct = 1.000
2+
d = 2, d2 = 4.0, pct = 0.500
3+
d = 3, d2 = 9.0, pct = 0.333
4+
d = 4, d2 = 16.0, pct = 0.250
5+
d = 5, d2 = 25.0, pct = 0.200
6+
d = 6, d2 = 36.0, pct = 0.167
7+
d = 7, d2 = 49.0, pct = 0.143
8+
d = 8, d2 = 64.0, pct = 0.125
9+
d = 9, d2 = 81.0, pct = 0.111
10+
d = 10, d2 = 100.0, pct = 0.100
11+
d = 11, d2 = 121.0, pct = 0.091
12+
d = 12, d2 = 144.0, pct = 0.083
13+
d = 13, d2 = 169.0, pct = 0.077
14+
d = 14, d2 = 196.0, pct = 0.071
15+
d = 15, d2 = 225.0, pct = 0.067
16+
d = 16, d2 = 256.0, pct = 0.063
17+
d = 17, d2 = 289.0, pct = 0.059
18+
d = 18, d2 = 324.0, pct = 0.056
19+
d = 19, d2 = 361.0, pct = 0.053
20+
d = 20, d2 = 400.0, pct = 0.050
21+
d = 21, d2 = 441.0, pct = 0.048
22+
d = 22, d2 = 484.0, pct = 0.045
23+
d = 23, d2 = 529.0, pct = 0.043
24+
d = 24, d2 = 576.0, pct = 0.042
25+
d = 25, d2 = 625.0, pct = 0.040
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import scala.util.continuations._
2+
3+
object Test {
4+
abstract class IfReturnRepro {
5+
def s1: Double @cpsParam[Any, Unit]
6+
def s2: Double @cpsParam[Any, Unit]
7+
8+
def p(i: Int): Double @cpsParam[Unit, Any] = {
9+
val px = s1
10+
val pct = if (px > 100) px else px / s2
11+
println("pct = %.3f".format(pct))
12+
pct
13+
}
14+
}
15+
16+
def main(args: Array[String]) : Unit = {
17+
var d: Double = 0d
18+
def d2 = d * d
19+
20+
val irr = new IfReturnRepro {
21+
def s1 = shift(f => f(d))
22+
def s2 = shift(f => f(d2))
23+
}
24+
1 to 25 foreach { i =>
25+
d = i
26+
print("d = " + i + ", d2 = " + d2 + ", ")
27+
run(irr p i)
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)