Let's just call it add.

This commit is contained in:
Alexander McCord 2024-05-27 20:52:19 -07:00
parent c8a1651c89
commit 994efce30a
2 changed files with 8 additions and 3 deletions

View file

@ -53,8 +53,7 @@ struct EGraph final
return std::nullopt; return std::nullopt;
} }
// TODO: `add`. For now, we call it shoveItIn so it's obvious it's just for testing. Id add(L enode)
Id shoveItIn(L enode)
{ {
if (auto id = lookup(enode)) if (auto id = lookup(enode))
return *id; return *id;

View file

@ -2,6 +2,7 @@
#include <doctest.h> #include <doctest.h>
#include "Luau/EGraph.h" #include "Luau/EGraph.h"
#include "Luau/Id.h"
#include "Luau/Language.h" #include "Luau/Language.h"
#include <optional> #include <optional>
@ -38,7 +39,12 @@ TEST_CASE("egraph_hashconsing")
{ {
EGraph egraph; 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(); TEST_SUITE_END();