-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
feature_check
workspace crate to test feature macro hygiene.
New `feature_check` crate is a non-default member of the workspace and verifies that the `storage_types!` macro expands properly based on `uom`'s features and not features in the calling crate. Part of #61.
- Loading branch information
1 parent
e0aa5ad
commit d0efe67
Showing
5 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "feature_check" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
uom = { path = "../.." } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Validate that the feature_check crate has no `f32` feature and `storage_types!` still generates | ||
//! code for the `f32` type. | ||
//! | ||
//! ``` | ||
//! #[macro_use] | ||
//! extern crate uom; | ||
//! | ||
//! #[cfg(feature = "f32")] | ||
//! compile_error!("Unexpected feature `f32` in feature_check test crate."); | ||
//! | ||
//! storage_types! { | ||
//! types: i32, f32; | ||
//! | ||
//! pub fn do_work(v: V) {} | ||
//! } | ||
//! | ||
//! fn main() { | ||
//! ::f32::do_work(1.0); | ||
//! } | ||
//! ``` | ||
//! | ||
//! Validate that `storage_types!` does not generate code for the `i32` type. | ||
//! | ||
//! ```rust,compile_fail | ||
//! #[macro_use] | ||
//! extern crate uom; | ||
//! | ||
//! storage_types! { | ||
//! types: i32, f32; | ||
//! | ||
//! pub fn do_work(v: V) {} | ||
//! } | ||
//! | ||
//! fn main() { | ||
//! ::i32::do_work(1.0); | ||
//! } | ||
//! ``` |