Specialize assert_pred
.
It has only two uses, and both use `matches_codepattern`. So just change it to `assert_matches_codepattern`.
This commit is contained in:
parent
95b4c07ef8
commit
13f2bc9a65
1 changed files with 6 additions and 12 deletions
|
@ -21,14 +21,12 @@ impl MutVisitor for ToZzIdentMutVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe add to `expand.rs`.
|
macro_rules! assert_matches_codepattern {
|
||||||
macro_rules! assert_pred {
|
($a:expr , $b:expr) => {{
|
||||||
($pred:expr, $predname:expr, $a:expr , $b:expr) => {{
|
|
||||||
let pred_val = $pred;
|
|
||||||
let a_val = $a;
|
let a_val = $a;
|
||||||
let b_val = $b;
|
let b_val = $b;
|
||||||
if !(pred_val(&a_val, &b_val)) {
|
if !matches_codepattern(&a_val, &b_val) {
|
||||||
panic!("expected args satisfying {}, got {} and {}", $predname, a_val, b_val);
|
panic!("expected args satisfying `matches_codepattern`, got {} and {}", a_val, b_val);
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -41,9 +39,7 @@ fn ident_transformation() {
|
||||||
let mut krate =
|
let mut krate =
|
||||||
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
|
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
|
||||||
zz_visitor.visit_crate(&mut krate);
|
zz_visitor.visit_crate(&mut krate);
|
||||||
assert_pred!(
|
assert_matches_codepattern!(
|
||||||
matches_codepattern,
|
|
||||||
"matches_codepattern",
|
|
||||||
print_crate_items(&krate),
|
print_crate_items(&krate),
|
||||||
"#[zz]mod zz{fn zz(zz:zz,zz:zz){zz!(zz,zz,zz);zz;zz}}".to_string()
|
"#[zz]mod zz{fn zz(zz:zz,zz:zz){zz!(zz,zz,zz);zz;zz}}".to_string()
|
||||||
);
|
);
|
||||||
|
@ -61,9 +57,7 @@ fn ident_transformation_in_defs() {
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
zz_visitor.visit_crate(&mut krate);
|
zz_visitor.visit_crate(&mut krate);
|
||||||
assert_pred!(
|
assert_matches_codepattern!(
|
||||||
matches_codepattern,
|
|
||||||
"matches_codepattern",
|
|
||||||
print_crate_items(&krate),
|
print_crate_items(&krate),
|
||||||
"macro_rules! zz{(zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+))}".to_string()
|
"macro_rules! zz{(zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+))}".to_string()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue