Skip to content

Instantly share code, notes, and snippets.

@insaneinside
Created March 20, 2015 23:20
Show Gist options
  • Save insaneinside/0cacc9634cc3bbb936e1 to your computer and use it in GitHub Desktop.
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
[package]
name="bob"
version="0.0.1"
authors=["insaneinside"]
[lib]
name="bob"
path="lib.rs"
/// 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