2018-11-24 07:34:13 -06:00
|
|
|
// force-host
|
2018-03-16 01:20:56 -05:00
|
|
|
// no-prefer-dynamic
|
|
|
|
|
|
|
|
#![crate_type = "proc-macro"]
|
|
|
|
|
|
|
|
extern crate proc_macro;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
2020-06-14 06:30:42 -05:00
|
|
|
assert_eq!(item.to_string(), "let string = \"Hello, world!\" ;");
|
2018-03-16 01:20:56 -05:00
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
2020-11-26 20:44:09 -06:00
|
|
|
pub fn expect_my_macro_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
|
2018-03-16 01:20:56 -05:00
|
|
|
assert!(attr.to_string().is_empty());
|
2021-05-01 14:54:47 -05:00
|
|
|
assert_eq!(item.to_string(), "my_macro! (\"{}\", string) ;");
|
2018-03-16 01:20:56 -05:00
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
|
|
|
assert_eq!(item.to_string(), "print_str(\"string\")");
|
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
2020-11-26 20:44:09 -06:00
|
|
|
pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
|
2018-03-16 01:20:56 -05:00
|
|
|
assert!(attr.to_string().is_empty());
|
2021-05-01 14:54:47 -05:00
|
|
|
assert_eq!(item.to_string(), "my_macro! (\"{}\", string)");
|
2018-03-16 01:20:56 -05:00
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
|
|
|
format!("{}, {}", item, item).parse().unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
|
|
|
assert!(!item.to_string().is_empty());
|
|
|
|
"".parse().unwrap()
|
|
|
|
}
|