Skip to content

Commit 0997f9b

Browse files
authored
[Outlining] Separating Filter Branch & Return Tests (#7401)
In the interest of improved test readability, moved the return part of the FilterBranches test into its own test. Also condensed the test to remove the unnecessary consts.
1 parent 1f01a77 commit 0997f9b

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

test/gtest/stringify.cpp

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -343,47 +343,51 @@ TEST_F(StringifyTest, FilterLocalSets) {
343343
SuffixTree::RepeatedSubstring{2u, (std::vector<unsigned>{6, 16})}}));
344344
}
345345

346-
// TODO: Switching to the new parser broke this test. Fix it.
346+
// TODO: Add support for outlining the below block. This block is valid to
347+
// outline because the branch within has a target that would also be included
348+
// in the outlined function.
349+
TEST_F(StringifyTest, FilterBranches) {
350+
static auto branchesModuleText = R"wasm(
351+
(module
352+
(func $a
353+
(block $top
354+
(br $top)
355+
)
356+
)
357+
(func $b
358+
(block $top
359+
(br $top)
360+
)
361+
)
362+
)
363+
)wasm";
364+
Module wasm;
365+
parseWast(wasm, branchesModuleText);
366+
HashStringifyWalker stringify = HashStringifyWalker();
367+
stringify.walkModule(&wasm);
368+
auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString);
369+
auto result = StringifyProcessor::filterBranches(substrings, stringify.exprs);
347370

348-
// TEST_F(StringifyTest, FilterBranches) {
349-
// static auto branchesModuleText = R"wasm(
350-
// (module
351-
// (func $a (result i32)
352-
// (block $top (result i32)
353-
// (br $top)
354-
// )
355-
// (i32.const 7)
356-
// (i32.const 1)
357-
// (i32.const 2)
358-
// (i32.const 4)
359-
// (i32.const 3)
360-
// (return)
361-
// )
362-
// (func $b (result i32)
363-
// (block $top (result i32)
364-
// (br $top)
365-
// )
366-
// (i32.const 0)
367-
// (i32.const 1)
368-
// (i32.const 2)
369-
// (i32.const 5)
370-
// (i32.const 3)
371-
// (return)
372-
// )
373-
// )
374-
// )wasm";
375-
// Module wasm;
376-
// parseWast(wasm, branchesModuleText);
377-
// HashStringifyWalker stringify = HashStringifyWalker();
378-
// stringify.walkModule(&wasm);
379-
// auto substrings =
380-
// StringifyProcessor::repeatSubstrings(stringify.hashString);
381-
// auto result =
382-
// StringifyProcessor::filterBranches(substrings, stringify.exprs);
371+
EXPECT_EQ(result, (std::vector<SuffixTree::RepeatedSubstring>{}));
372+
}
383373

384-
// EXPECT_EQ(
385-
// result,
386-
// (std::vector<SuffixTree::RepeatedSubstring>{
387-
// // sequence i32.const 1, i32.const 2 is at idx 6 and 21
388-
// SuffixTree::RepeatedSubstring{2u, (std::vector<unsigned>{6, 21})}}));
389-
// }
374+
TEST_F(StringifyTest, FilterReturn) {
375+
static auto branchesModuleText = R"wasm(
376+
(module
377+
(func $a (result i32)
378+
(return (i32.const 0))
379+
)
380+
(func $b (result i32)
381+
(return (i32.const 0))
382+
)
383+
)
384+
)wasm";
385+
Module wasm;
386+
parseWast(wasm, branchesModuleText);
387+
HashStringifyWalker stringify = HashStringifyWalker();
388+
stringify.walkModule(&wasm);
389+
auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString);
390+
auto result = StringifyProcessor::filterBranches(substrings, stringify.exprs);
391+
392+
EXPECT_EQ(result, (std::vector<SuffixTree::RepeatedSubstring>{}));
393+
}

0 commit comments

Comments
 (0)