Created
March 20, 2015 23:20
-
-
Save insaneinside/0cacc9634cc3bbb936e1 to your computer and use it in GitHub Desktop.
Example of Cargo- and rustdoc-built tests failing for tests derived from macro doc-comments
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
[package] | |
name="bob" | |
version="0.0.1" | |
authors=["insaneinside"] | |
[lib] | |
name="bob" | |
path="lib.rs" |
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
/// Panic with a given message unless an expression evaluates to true. | |
/// | |
/// ## Examples | |
/// ```rust | |
/// panic_unless!(1 + 1 == 2, "Math is broken."); | |
/// ``` | |
/// | |
/// ```rust,should_fail | |
/// panic_unless!(true == false, "I'm broken."); | |
/// ``` | |
#[macro_export] | |
macro_rules! panic_unless { | |
($condition:expr, $($rest:expr),+) => ({ if ! $condition { panic!($($rest),+); } }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment