From 994efce30a2f08680436111c05dfd46e5c7069d7 Mon Sep 17 00:00:00 2001 From: Alexander McCord Date: Mon, 27 May 2024 20:52:19 -0700 Subject: [PATCH] Let's just call it `add`. --- EqSat/include/Luau/EGraph.h | 3 +-- tests/EqSat.propositional.test.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/EqSat/include/Luau/EGraph.h b/EqSat/include/Luau/EGraph.h index d2099f3c..96e0ed3d 100644 --- a/EqSat/include/Luau/EGraph.h +++ b/EqSat/include/Luau/EGraph.h @@ -53,8 +53,7 @@ struct EGraph final return std::nullopt; } - // TODO: `add`. For now, we call it shoveItIn so it's obvious it's just for testing. - Id shoveItIn(L enode) + Id add(L enode) { if (auto id = lookup(enode)) return *id; diff --git a/tests/EqSat.propositional.test.cpp b/tests/EqSat.propositional.test.cpp index 81248a7c..723fd104 100644 --- a/tests/EqSat.propositional.test.cpp +++ b/tests/EqSat.propositional.test.cpp @@ -2,6 +2,7 @@ #include #include "Luau/EGraph.h" +#include "Luau/Id.h" #include "Luau/Language.h" #include @@ -38,7 +39,12 @@ TEST_CASE("egraph_hashconsing") { EGraph egraph; - CHECK(egraph.shoveItIn(Bool{true}) == egraph.shoveItIn(Bool{true})); + EqSat::Id id1 = egraph.add(Bool{true}); + EqSat::Id id2 = egraph.add(Bool{true}); + EqSat::Id id3 = egraph.add(Bool{false}); + + CHECK(id1 == id2); + CHECK(id2 != id3); } TEST_SUITE_END();