- Notifications
You must be signed in to change notification settings - Fork268
check_unique
refactor#667
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:pfb/unique-checking
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -222,6 +222,21 @@ mod test { | ||
pdg.graphs[0_u32.into()].nodes[id].info.as_ref().unwrap() | ||
} | ||
fn check_unique(pdg: &Graphs, unique: &[NodeId], non_unique: &[NodeId]) { | ||
for &unique in unique { | ||
assert!( | ||
info(pdg, unique).unique, | ||
"expected {unique} to be unique in {pdg}" | ||
); | ||
} | ||
for &non_unique in non_unique { | ||
assert!( | ||
!info(pdg, non_unique).unique, | ||
"expected {non_unique} to be non-unique in {pdg}" | ||
); | ||
} | ||
} | ||
/// ```rust | ||
/// let mut a = 0; | ||
/// let b = &mut a; | ||
@@ -262,14 +277,7 @@ mod test { | ||
let c3 = mk_store_addr(&mut g, c1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, b1, b2, b3, c1, c2, c3]); | ||
} | ||
/// ```rust | ||
@@ -308,12 +316,7 @@ mod test { | ||
let b3 = mk_store_addr(&mut g, b1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, b1, b2, b3, c1, c2]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. having these two arguments really doesn't make clear that you're checking for non-uniqueness here, in addition to the function name. i suggest having one function for each There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah, that might be better. Might not be worth changing, though, given#668. | ||
} | ||
/// ```rust | ||
@@ -352,12 +355,7 @@ mod test { | ||
let b3 = mk_store_addr(&mut g, b1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, b1, b2, b3, c1, c2], &[]); | ||
} | ||
/// ```rust | ||
@@ -400,13 +398,7 @@ mod test { | ||
let c3 = mk_store_addr(&mut g, c1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a], &[b1, b2, b3, c1, c2, c3]); | ||
} | ||
/// ```rust | ||
@@ -444,11 +436,7 @@ mod test { | ||
let c2 = mk_store_addr(&mut g, c1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, b1, b2, c1, c2], &[]); | ||
} | ||
/// ```rust | ||
@@ -497,13 +485,7 @@ mod test { | ||
let d2 = mk_store_addr(&mut g, d1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, d2], &[j, b1, b2, c1, c2]); | ||
} | ||
/// ```rust | ||
@@ -540,11 +522,7 @@ mod test { | ||
let b2 = mk_store_addr(&mut g, b1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, b1, b2, c1, c2]); | ||
} | ||
/// ```rust | ||
@@ -583,12 +561,7 @@ mod test { | ||
let b2 = mk_store_addr(&mut g, bb); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, b1, b2, c1, c2]); | ||
} | ||
/// ```rust | ||
@@ -645,24 +618,11 @@ mod test { | ||
let x6 = mk_store_addr(&mut g, x5); | ||
let pdg = build_pdg(g); | ||
check_unique( | ||
&pdg, | ||
&[a, b1, c1, x1, x2, x3, b2, c2, d1, d2, x4, x5, x6], | ||
&[e, f1, gg, f2], | ||
); | ||
} | ||
/// ```rust | ||
@@ -705,14 +665,7 @@ mod test { | ||
let y3 = mk_store_addr(&mut g, y1); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, x1, x2, x3, y1, y2, y3], &[]); | ||
} | ||
/// ```rust | ||
@@ -759,16 +712,7 @@ mod test { | ||
let y4 = mk_store_addr(&mut g, y2); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, x1, x2, x3, x4, y1, y2, y3, y4], &[]); | ||
} | ||
/// ```rust | ||
@@ -815,16 +759,7 @@ mod test { | ||
let y4 = mk_store_addr(&mut g, y2); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, x1, x2, x3, x4, y1, y2, y3, y4]); | ||
} | ||
/// ```rust | ||
@@ -871,16 +806,7 @@ mod test { | ||
let y4 = mk_store_addr(&mut g, y2); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[a, x1, x2, x3, x4, y1, y2, y3, y4]); | ||
} | ||
/// ```rust | ||
@@ -927,16 +853,7 @@ mod test { | ||
let y4 = mk_store_addr(&mut g, y2); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[a, x1, x2, x3, x4, y1, y2, y3, y4], &[]); | ||
} | ||
/// ```rust | ||
@@ -992,15 +909,6 @@ mod test { | ||
let y4 = mk_store_addr(&mut g, y2); | ||
let pdg = build_pdg(g); | ||
check_unique(&pdg, &[], &[p, x1, x2, x3, x4, y1, y2, y3, y4]); | ||
} | ||
} |