add tests I forgot to add

This commit is contained in:
Niko Matsakis 2011-12-21 08:41:41 -08:00
parent 627217fa55
commit 66856a39b3
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,12 @@
// error-pattern: copying a noncopyable value
fn to_lambda1(f: lambda(uint) -> uint) -> lambda(uint) -> uint {
ret f;
}
fn to_lambda2(b: block(uint) -> uint) -> lambda(uint) -> uint {
ret to_lambda1({|x| b(x)});
}
fn main() {
}

View file

@ -0,0 +1,14 @@
fn to_lambda(f: lambda(uint) -> uint) -> lambda(uint) -> uint {
ret f;
}
fn main() {
let x: lambda(uint) -> uint = to_lambda({ |x| x * 2u });
let y = to_lambda(x);
let x_r = x(22u);
let y_r = y(x_r);
assert x_r == 44u;
assert y_r == 88u;
}