Improve testing of the codegen system

- Move codegen tests to a sub directory
- Add tests for all functions of Expression, ExpressionRef, and ExpressionGraph
- Respect dependencies during tests: The ExpressionGraph test doesn't
  use ExpressionRef anymore.

The new tests revealed a few bugs so the following changes were made:

- Expression::MakeNop now resets the current expression with the default
  constructed NOP expression
- ExpressionGraph::Insert now updates the lhs_id the same way as
  InsertBack()

Change-Id: I6a18925c1e4d972c29ec1219f2073b4eaf2df737
This commit is contained in:
Darius Rueckert
2019-12-06 18:26:31 +01:00
parent 572ec4a5a5
commit f4dc670ee8
12 changed files with 734 additions and 466 deletions
@@ -249,6 +249,7 @@ enum class ExpressionType {
// ExpressionGraph (see expression_graph.h).
class Expression {
public:
// Creates a NOP expression.
Expression() = default;
Expression(ExpressionType type,
@@ -53,6 +53,9 @@ class ExpressionGraph {
bool DependsOn(ExpressionId A, ExpressionId B) const;
bool operator==(const ExpressionGraph& other) const;
bool operator!=(const ExpressionGraph& other) const {
return !(*this == other);
}
Expression& ExpressionForId(ExpressionId id) { return expressions_[id]; }
const Expression& ExpressionForId(ExpressionId id) const {