rust/src/test/run-pass/macro-2.rs

21 lines
436 B
Rust
Raw Normal View History

// xfail-pretty - token trees can't pretty print
2011-06-27 12:58:05 -05:00
fn main() {
#macro[[#mylambda[x, body],
{
2012-08-01 19:30:05 -05:00
fn f(x: int) -> int { return body; }
f
}]];
assert (mylambda!{y, y * 2}(8) == 16);
macro_rules! mylambda_tt{
{$x:ident, $body:expr} => {
2012-08-01 19:30:05 -05:00
fn f($x: int) -> int { return $body; };
f
}
}
assert(mylambda_tt!{y, y * 2}(8) == 16)
}