Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b-studios committed Nov 27, 2023
1 parent 86834d8 commit 514b089
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/pos/lambdalifting/nested.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inner Handler!
12 changes: 12 additions & 0 deletions examples/pos/lambdalifting/nested.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
effect raise(): Int


def main() =
try {
val x = {
def f(n: Int): Int / {} = { do raise(); if (n == 0) { f(7) ; do raise() } else 4 }
f(1)
f(2)
}
println(x)
} with e1: raise { println("Inner Handler!") }
1 change: 1 addition & 0 deletions examples/pos/lambdalifting/nestedif.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inner Handler!
16 changes: 16 additions & 0 deletions examples/pos/lambdalifting/nestedif.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
effect raise(): Int


def main() =
try {
val x = {
def f(n: Int): Int / {} =
{
val z = if (true) do raise() else { do raise() + 1 };
z
}
val z = f(1);
f(2)
}
println(x)
} with e1: raise { println("Inner Handler!") }
1 change: 1 addition & 0 deletions examples/pos/lambdalifting/patternmatching.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
18 changes: 18 additions & 0 deletions examples/pos/lambdalifting/patternmatching.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type Foo {
Bar(n: Int);
Baz()
}

def consume(f: Foo) = {
val res = f match {
case Bar(n) => n + 1
case Baz() => 0
}
res * 2
}

def main() = {
val x = consume(Bar(1));
val y = consume(Baz());
println(x + y)
}

0 comments on commit 514b089

Please sign in to comment.