File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
effekt/jvm/src/test/scala/effekt/core Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -819,6 +819,21 @@ class VMTests extends munit.FunSuite {
819
819
shifts = 0 ,
820
820
resumes = 0
821
821
)),
822
+ examplesDir / " pos" / " diy_binder.effekt" -> Some (Summary (
823
+ staticDispatches = 28 ,
824
+ dynamicDispatches = 0 ,
825
+ patternMatches = 28 ,
826
+ branches = 26 ,
827
+ pushedFrames = 1 ,
828
+ poppedFrames = 1 ,
829
+ allocations = 30 ,
830
+ closures = 0 ,
831
+ variableReads = 28 ,
832
+ variableWrites = 29 ,
833
+ resets = 0 ,
834
+ shifts = 0 ,
835
+ resumes = 0
836
+ )),
822
837
)
823
838
824
839
val testFiles : Seq [(File , Option [Summary ])] =
Original file line number Diff line number Diff line change
1
+ 12
2
+ 11
3
+ 10
4
+ 9
5
+ 8
6
+ 7
7
+ 6
8
+ 5
9
+ 4
10
+ 3
11
+ 2
12
+ 1
13
+ 0
14
+ 12
15
+ 11
16
+ 10
17
+ 9
18
+ 8
19
+ 7
20
+ 6
21
+ 5
22
+ 4
23
+ 3
24
+ 2
25
+ 1
26
+ 0
Original file line number Diff line number Diff line change
1
+ effect lookupX(): Int
2
+
3
+ // With parametric polymorphism on effects, this could be
4
+ // def whil[E: EffectSet]{ cond: [R]{ => R / E }{ => R } => R }{ body: => Unit / E }: Unit
5
+ def whil{ cond: [R]{ => R / lookupX }{ => R } => R }{ body: => Unit / lookupX }: Unit = {
6
+ cond{ body(); whil{cond}{body} }{ () }
7
+ }
8
+
9
+ def main() = {
10
+ var x = Some(12)
11
+ // desugared cond
12
+ def cond[R]{thn: => R / lookupX}{els: => R} = {
13
+ if(x is Some(y)){
14
+ try { thn() } with lookupX{ () => resume(y) }
15
+ } else { els() }
16
+ }
17
+ whil{ cond }{
18
+ println(do lookupX())
19
+ x = Some(do lookupX() - 1)
20
+ if (do lookupX() == 0) {
21
+ x = None()
22
+ }
23
+ }
24
+ x = Some(12)
25
+ whil{ cond }{
26
+ println(do lookupX())
27
+ x = Some(do lookupX() - 1)
28
+ if (do lookupX() == 0) {
29
+ x = None()
30
+ }
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments