Skip to content

Commit

Permalink
[analysis][NFC] Refactor lattice unit tests
Browse files Browse the repository at this point in the history
Many of the lattice tests were essentially copy-pasted from one lattice to the
next because they all tested isomorphic subsets of the various lattices,
specifically in the shape of a diamond. Refactor the code so that all lattices
that have tests of this shape use the same utility test functions.
  • Loading branch information
tlively committed Oct 31, 2023
1 parent 33139e2 commit e8e0ab4
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 420 deletions.
7 changes: 7 additions & 0 deletions src/analysis/lattices/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ struct Flat {
bool isTop() const noexcept { return std::get_if<Top>(this); }
const T* getVal() const noexcept { return std::get_if<T>(this); }
T* getVal() noexcept { return std::get_if<T>(this); }
bool operator==(const Element& other) const noexcept {
return ((isBottom() && other.isBottom()) || (isTop() && other.isTop()) ||
(getVal() && other.getVal() && *getVal() == *other.getVal()));
}
bool operator!=(const Element& other) const noexcept {
return !(*this == other);
}
};

Element getBottom() const noexcept { return Element{Bot{}}; }
Expand Down
Loading

0 comments on commit e8e0ab4

Please sign in to comment.