summaryrefslogtreecommitdiff
path: root/test/gtest/stringify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/gtest/stringify.cpp')
-rw-r--r--test/gtest/stringify.cpp32
1 files changed, 6 insertions, 26 deletions
diff --git a/test/gtest/stringify.cpp b/test/gtest/stringify.cpp
index 8e854ee4b..59b7db6e1 100644
--- a/test/gtest/stringify.cpp
+++ b/test/gtest/stringify.cpp
@@ -250,29 +250,11 @@ TEST_F(StringifyTest, Stringify) {
}));
}
-std::vector<SuffixTree::RepeatedSubstring>
-repeatSubstrings(std::vector<uint32_t> hashString) {
- SuffixTree st(hashString);
- std::vector<SuffixTree::RepeatedSubstring> substrings(st.begin(), st.end());
- std::sort(
- substrings.begin(),
- substrings.end(),
- [](SuffixTree::RepeatedSubstring a, SuffixTree::RepeatedSubstring b) {
- size_t aWeight = a.Length * a.StartIndices.size();
- size_t bWeight = b.Length * b.StartIndices.size();
- if (aWeight == bWeight) {
- return a.StartIndices[0] < b.StartIndices[0];
- }
- return aWeight > bWeight;
- });
- return substrings;
-}
-
TEST_F(StringifyTest, Substrings) {
Module wasm;
parseWast(wasm, dupModuleText);
auto hashString = hashStringifyModule(&wasm);
- auto substrings = repeatSubstrings(hashString);
+ auto substrings = StringifyProcessor::repeatSubstrings(hashString);
EXPECT_EQ(
substrings,
@@ -294,7 +276,7 @@ TEST_F(StringifyTest, DedupeSubstrings) {
parseWast(wasm, dupModuleText);
auto hashString = hashStringifyModule(&wasm);
std::vector<SuffixTree::RepeatedSubstring> substrings =
- repeatSubstrings(hashString);
+ StringifyProcessor::repeatSubstrings(hashString);
auto result = StringifyProcessor::dedupe(substrings);
EXPECT_EQ(
@@ -332,10 +314,9 @@ TEST_F(StringifyTest, FilterLocalSets) {
parseWast(wasm, localSetModuleText);
HashStringifyWalker stringify = HashStringifyWalker();
stringify.walkModule(&wasm);
- auto substrings = repeatSubstrings(stringify.hashString);
- auto result = StringifyProcessor::dedupe(substrings);
-
- result = StringifyProcessor::filterLocalSets(substrings, stringify.exprs);
+ auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString);
+ auto result =
+ StringifyProcessor::filterLocalSets(substrings, stringify.exprs);
EXPECT_EQ(
result,
@@ -375,8 +356,7 @@ TEST_F(StringifyTest, FilterBranches) {
parseWast(wasm, branchesModuleText);
HashStringifyWalker stringify = HashStringifyWalker();
stringify.walkModule(&wasm);
-
- auto substrings = repeatSubstrings(stringify.hashString);
+ auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString);
auto result = StringifyProcessor::filterBranches(substrings, stringify.exprs);
EXPECT_EQ(