rustc --test test2.rs
Last active
January 8, 2023 19:16
-
-
Save nmarley/0831cf27ca12ce7e6b1234af8162e94e to your computer and use it in GitHub Desktop.
Rust macro testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! test_battery { | |
($($t:ty as $name:ident),*) => { | |
$( | |
mod $name { | |
#[test] | |
fn frobnified() { assert_eq!(true, true); } | |
#[test] | |
fn unfrobnified() { assert_eq!(false, false); } | |
} | |
)* | |
} | |
} | |
// seems to work | |
test_battery! (u8 as u8_tests, u128 as u128_tests); | |
// seems to work | |
test_battery! {u8 as u8_tests2, u128 as u128_tests2} | |
// seems to have a problem | |
test_battery! {u8 as u8_tests3, u128 as u128_tests3}; | |
fn main() { | |
println!("Hello, world!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment