Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
kkysen wants to merge2 commits intopfb/unique-checking
base:pfb/unique-checking
Choose a base branch
Loading
fromkkysen/pfb/unique-checking/check-unique-refactor
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 34 additions & 126 deletionspdg/src/info.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
Expand DownExpand Up@@ -262,14 +277,7 @@ mod test {
let c3 = mk_store_addr(&mut g, c1);

let pdg = build_pdg(g);
assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);

assert!(!info(&pdg, b3).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
assert!(!info(&pdg, c3).unique);
check_unique(&pdg, &[], &[a, b1, b2, b3, c1, c2, c3]);
}

/// ```rust
Expand DownExpand Up@@ -308,12 +316,7 @@ mod test {
let b3 = mk_store_addr(&mut g, b1);

let pdg = build_pdg(g);
assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);
assert!(!info(&pdg, b3).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
check_unique(&pdg, &[], &[a, b1, b2, b3, c1, c2]);
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The 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
Expand DownExpand Up@@ -352,12 +355,7 @@ mod test {
let b3 = mk_store_addr(&mut g, b1);

let pdg = build_pdg(g);
assert!(info(&pdg, a).unique);
assert!(info(&pdg, b1).unique);
assert!(info(&pdg, b2).unique);
assert!(info(&pdg, b3).unique);
assert!(info(&pdg, c1).unique);
assert!(info(&pdg, c2).unique);
check_unique(&pdg, &[a, b1, b2, b3, c1, c2], &[]);
}

/// ```rust
Expand DownExpand Up@@ -400,13 +398,7 @@ mod test {
let c3 = mk_store_addr(&mut g, c1);

let pdg = build_pdg(g);
assert!(info(&pdg, a).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);
assert!(!info(&pdg, b3).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
assert!(!info(&pdg, c3).unique);
check_unique(&pdg, &[a], &[b1, b2, b3, c1, c2, c3]);
}

/// ```rust
Expand DownExpand Up@@ -444,11 +436,7 @@ mod test {
let c2 = mk_store_addr(&mut g, c1);

let pdg = build_pdg(g);
assert!(info(&pdg, a).unique);
assert!(info(&pdg, b1).unique);
assert!(info(&pdg, b2).unique);
assert!(info(&pdg, c1).unique);
assert!(info(&pdg, c2).unique);
check_unique(&pdg, &[a, b1, b2, c1, c2], &[]);
}

/// ```rust
Expand DownExpand Up@@ -497,13 +485,7 @@ mod test {
let d2 = mk_store_addr(&mut g, d1);

let pdg = build_pdg(g);
assert!(info(&pdg, a).unique);
assert!(!info(&pdg, j).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
assert!(info(&pdg, d2).unique);
check_unique(&pdg, &[a, d2], &[j, b1, b2, c1, c2]);
}

/// ```rust
Expand DownExpand Up@@ -540,11 +522,7 @@ mod test {
let b2 = mk_store_addr(&mut g, b1);

let pdg = build_pdg(g);
assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
check_unique(&pdg, &[], &[a, b1, b2, c1, c2]);
}

/// ```rust
Expand DownExpand Up@@ -583,12 +561,7 @@ mod test {
let b2 = mk_store_addr(&mut g, bb);

let pdg = build_pdg(g);
assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, b1).unique);
assert!(!info(&pdg, b2).unique);
assert!(!info(&pdg, c1).unique);
assert!(!info(&pdg, c2).unique);
assert!(!info(&pdg, b2).unique);
check_unique(&pdg, &[], &[a, b1, b2, c1, c2]);
}

/// ```rust
Expand DownExpand Up@@ -645,24 +618,11 @@ mod test {
let x6 = mk_store_addr(&mut g, x5);

let pdg = build_pdg(g);

assert!(info(&pdg, a).unique);
assert!(info(&pdg, b1).unique);
assert!(info(&pdg, c1).unique);
assert!(info(&pdg, x1).unique);
assert!(info(&pdg, x2).unique);
assert!(info(&pdg, x3).unique);
assert!(info(&pdg, b2).unique);
assert!(info(&pdg, c2).unique);
assert!(info(&pdg, d1).unique);
assert!(info(&pdg, d2).unique);
assert!(!info(&pdg, e).unique);
assert!(!info(&pdg, f1).unique);
assert!(!info(&pdg, gg).unique);
assert!(!info(&pdg, f2).unique);
assert!(info(&pdg, x4).unique);
assert!(info(&pdg, x5).unique);
assert!(info(&pdg, x6).unique);
check_unique(
&pdg,
&[a, b1, c1, x1, x2, x3, b2, c2, d1, d2, x4, x5, x6],
&[e, f1, gg, f2],
);
}

/// ```rust
Expand DownExpand Up@@ -705,14 +665,7 @@ mod test {
let y3 = mk_store_addr(&mut g, y1);

let pdg = build_pdg(g);

assert!(info(&pdg, a).unique);
assert!(info(&pdg, x1).unique);
assert!(info(&pdg, x2).unique);
assert!(info(&pdg, x3).unique);
assert!(info(&pdg, y1).unique);
assert!(info(&pdg, y2).unique);
assert!(info(&pdg, y3).unique);
check_unique(&pdg, &[a, x1, x2, x3, y1, y2, y3], &[]);
}

/// ```rust
Expand DownExpand Up@@ -759,16 +712,7 @@ mod test {
let y4 = mk_store_addr(&mut g, y2);

let pdg = build_pdg(g);

assert!(info(&pdg, a).unique);
assert!(info(&pdg, x1).unique);
assert!(info(&pdg, x2).unique);
assert!(info(&pdg, x3).unique);
assert!(info(&pdg, x4).unique);
assert!(info(&pdg, y1).unique);
assert!(info(&pdg, y2).unique);
assert!(info(&pdg, y3).unique);
assert!(info(&pdg, y4).unique);
check_unique(&pdg, &[a, x1, x2, x3, x4, y1, y2, y3, y4], &[]);
}

/// ```rust
Expand DownExpand Up@@ -815,16 +759,7 @@ mod test {
let y4 = mk_store_addr(&mut g, y2);

let pdg = build_pdg(g);

assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, x1).unique);
assert!(!info(&pdg, x2).unique);
assert!(!info(&pdg, x3).unique);
assert!(!info(&pdg, x4).unique);
assert!(!info(&pdg, y1).unique);
assert!(!info(&pdg, y2).unique);
assert!(!info(&pdg, y3).unique);
assert!(!info(&pdg, y4).unique);
check_unique(&pdg, &[], &[a, x1, x2, x3, x4, y1, y2, y3, y4]);
}

/// ```rust
Expand DownExpand Up@@ -871,16 +806,7 @@ mod test {
let y4 = mk_store_addr(&mut g, y2);

let pdg = build_pdg(g);

assert!(!info(&pdg, a).unique);
assert!(!info(&pdg, x1).unique);
assert!(!info(&pdg, x2).unique);
assert!(!info(&pdg, x3).unique);
assert!(!info(&pdg, x4).unique);
assert!(!info(&pdg, y1).unique);
assert!(!info(&pdg, y2).unique);
assert!(!info(&pdg, y3).unique);
assert!(!info(&pdg, y4).unique);
check_unique(&pdg, &[], &[a, x1, x2, x3, x4, y1, y2, y3, y4]);
}

/// ```rust
Expand DownExpand Up@@ -927,16 +853,7 @@ mod test {
let y4 = mk_store_addr(&mut g, y2);

let pdg = build_pdg(g);

assert!(info(&pdg, a).unique);
assert!(info(&pdg, x1).unique);
assert!(info(&pdg, x2).unique);
assert!(info(&pdg, x3).unique);
assert!(info(&pdg, x4).unique);
assert!(info(&pdg, y1).unique);
assert!(info(&pdg, y2).unique);
assert!(info(&pdg, y3).unique);
assert!(info(&pdg, y4).unique);
check_unique(&pdg, &[a, x1, x2, x3, x4, y1, y2, y3, y4], &[]);
}

/// ```rust
Expand DownExpand Up@@ -992,15 +909,6 @@ mod test {
let y4 = mk_store_addr(&mut g, y2);

let pdg = build_pdg(g);

assert!(!info(&pdg, p).unique);
assert!(!info(&pdg, x1).unique);
assert!(!info(&pdg, x2).unique);
assert!(!info(&pdg, x3).unique);
assert!(!info(&pdg, x4).unique);
assert!(!info(&pdg, y1).unique);
assert!(!info(&pdg, y2).unique);
assert!(!info(&pdg, y3).unique);
assert!(!info(&pdg, y4).unique);
check_unique(&pdg, &[], &[p, x1, x2, x3, x4, y1, y2, y3, y4]);
}
}

[8]ページ先頭

©2009-2025 Movatter.jp