]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-stmt.rs
Move /src/test to /tests
[rust.git] / tests / ui / macros / macro-stmt.rs
1 // run-pass
2 macro_rules! myfn {
3     ( $f:ident, ( $( $x:ident ),* ), $body:block ) => (
4         fn $f( $( $x : isize),* ) -> isize $body
5     )
6 }
7
8 myfn!(add, (a,b), { return a+b; } );
9
10 pub fn main() {
11
12     macro_rules! mylet {
13         ($x:ident, $val:expr) => (
14             let $x = $val;
15         )
16     }
17
18     mylet!(y, 8*2);
19     assert_eq!(y, 16);
20
21     myfn!(mult, (a,b), { a*b } );
22
23     assert_eq!(mult(2, add(4,4)), 16);
24
25     macro_rules! actually_an_expr_macro {
26         () => ( 16 )
27     }
28
29     assert_eq!({ actually_an_expr_macro!() }, 16);
30
31 }