Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create declarative macro which helps intellij recognize individual test cases #21

Open
foresterre opened this issue Dec 14, 2019 · 3 comments
Labels
C-enhancement Category: enhancements

Comments

@foresterre
Copy link
Owner

/// FIXME:
/// Create individual test cases which are recognized by intellij as tests, similar to the ide!()
/// macro, but for individual test cases.
///
/// ```rust
///
/// #[parameterized(
///     a = { 1, 2, 3 },
///     b = { 5, 6, 7},
/// )]
/// mktest! le_test(a: i32, b: i32) {
///     assert!(a < 4 && b > 4);
/// }
/// ```
/// 
/// generates:
/// 
/// ```rust
/// 
/// mod le_test {
///     use super::*;
///
///     ide!();
/// 
///     #[parameterized(
///         a = { 1, 2, 3 },
///         b = { 5, 6, 7},
///     )]
///     fn le_test(a: i32, b: i32) {
///         assert!(a < 4 && b > 4);
///     } 
/// }
/// ```
@foresterre foresterre changed the title Create macro which helps intellij recognized individual test cases Create declarative macro which helps intellij recognized individual test cases Dec 14, 2019
@idubrov
Copy link

idubrov commented Jan 17, 2020

Another way is to allow specifying #[test] after #[parameterized(..)] (by making parameterized macro to remove #[test]):

#[parameterized(
  a = { 1, 2, 3 },
  b = { 5, 6, 7},
)]
#[test]
fn le_test(a: i32, b: i32) {
  assert!(a < 4 && b > 4);
} 

Which is non-ideal (you can only put it after #[parameterized(..)), but works okay (this is how we do it in datatest).

@foresterre
Copy link
Owner Author

foresterre commented Jan 18, 2020

Another way is to allow specifying #[test] after #[parameterized(..)] (by making parameterized macro to remove #[test]):

#[parameterized(
  a = { 1, 2, 3 },
  b = { 5, 6, 7},
)]
#[test]
fn le_test(a: i32, b: i32) {
  assert!(a < 4 && b > 4);
} 

Which is non-ideal (you can only put it after #[parameterized(..)), but works okay (this is how we do it in datatest).

Oh wow :), that's a great idea. Thank you! I will look into this.

@foresterre foresterre changed the title Create declarative macro which helps intellij recognized individual test cases Create declarative macro which helps intellij recognize individual test cases Jan 18, 2020
@foresterre foresterre added the C-enhancement Category: enhancements label Jan 18, 2020
@foresterre
Copy link
Owner Author

foresterre commented Apr 29, 2020

  • experiment:

declarative macro for which wraps ide! construct, test inputs and test cases

  • Doesn't work in intellij 2019.x with Intellij Rust + latest macro expansion engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancements
Projects
None yet
Development

No branches or pull requests

2 participants