Skip to content

Commit

Permalink
simpler yage test macro
Browse files Browse the repository at this point in the history
no need to make a repetition with a pattern matching recurssion, it's already
available in the macro syntax
  • Loading branch information
glehmann committed Feb 8, 2024
1 parent 378a167 commit 21adb7c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,11 @@ impl TestString for String {

#[macro_export]
macro_rules! yage {
() => (
Command::cargo_bin("yage").unwrap().assert()
);
( $( $v:expr ),* ) => (
yage_args!(Command::cargo_bin("yage").unwrap(), $($v),*).assert()
);
}

#[macro_export]
macro_rules! yage_args {
($x:expr) => ($x);
($x:expr, $y:expr) => ($x.arg($y));
($x:expr, $y:expr, $($z:expr),+) => (
yage_args!($x.arg($y), $($z),*)
);
( $( $v:expr ),* ) => ({
let mut cmd = Command::cargo_bin("yage").unwrap();
$(
cmd.arg($v);
)*
cmd.assert()
});
}

0 comments on commit 21adb7c

Please sign in to comment.