Skip to content

Commit

Permalink
add a test, fix a bug, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
rrbutani committed Sep 21, 2019
1 parent a8dc2af commit 39d8b06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,13 @@ impl IdentifierReplace<'_> {

impl VisitMut for IdentifierReplace<'_> {
fn visit_expr_mut(&mut self, expr: &mut Expr) {
println!("{:?}", expr);
// println!("{:?}", expr);

if let Expr::Path(ExprPath { path, .. }) = expr {
println!("match!!! {:?}", path);
if path.is_ident(self.identifier_name) {
*expr = parse_quote!(#(self.substitution));
let num = self.substitution;
*expr = parse_quote!(#num);
return;
}
// This is unfortunately not permitted:
Expand Down
13 changes: 9 additions & 4 deletions tests/repeat_n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ mod tests {
#[allow(unused)]
struct Bar<const B: usize>;

// #[test]
// fn test() {
// repeat_with_n!(10, n, { impl Foo for Bar<{n as usize}> {} });
// }
#[test]
fn test() {
repeat_with_n!(10, n, { impl Foo for Bar<{n as usize}> {} });
}

#[test]
fn with_macro() {
repeat_with_n!(10, longer_identifier, { println!("{}", longer_identifier); });
}

#[test]
fn nested_macro() {
repeat_with_n!(10, y, { println!("{}", format!("{}", format!("{}{}{}{}", y, y, y, y))); });
}
}

0 comments on commit 39d8b06

Please sign in to comment.