2024-02-16 20:02:50 +00:00
|
|
|
//@ force-host
|
|
|
|
//@ no-prefer-dynamic
|
2018-03-15 23:20:56 -07:00
|
|
|
|
|
|
|
#![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());
|
2023-08-08 11:43:44 +10:00
|
|
|
assert_eq!(item.to_string(), "let string = \"Hello, world!\";");
|
2018-03-15 23:20:56 -07:00
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
2023-10-12 15:36:14 +11:00
|
|
|
assert_eq!(item.to_string(), "println!(\"{}\", string);");
|
2018-03-15 23:20:56 -07: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]
|
|
|
|
pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
2023-08-08 11:43:44 +10:00
|
|
|
assert_eq!(item.to_string(), "println!(\"{}\", string)");
|
2018-03-15 23:20:56 -07:00
|
|
|
item
|
|
|
|
}
|
2018-04-02 17:21:37 -07:00
|
|
|
|
|
|
|
#[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()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn noop(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
assert!(attr.to_string().is_empty());
|
|
|
|
assert!(!item.to_string().is_empty());
|
|
|
|
item
|
|
|
|
}
|