Skip to content

Commit 418aa52

Browse files
msullivanbrson
authored andcommitted
Add a test that exercises these cases in bind.
1 parent cd97f4e commit 418aa52

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// xfail-stage0
2+
3+
fn fix_help[A,B](@fn (@fn (&A) -> B, &A) -> B f, &A x) -> B {
4+
ret f(@bind fix_help(f, _), x);
5+
}
6+
7+
fn fix[A,B](@fn (@fn (&A) -> B, &A) -> B f) -> (@fn(&A) -> B) {
8+
ret @bind fix_help(f, _);
9+
}
10+
11+
fn fact_(@fn (&int) -> int f, &int n) -> int {
12+
// fun fact 0 = 1
13+
ret if (n == 0) { 1 } else { n*f(n-1) };
14+
}
15+
16+
fn main() {
17+
auto fact = fix(@fact_);
18+
assert(fact(5) == 120);
19+
assert(fact(2) == 2);
20+
}

0 commit comments

Comments
 (0)