summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-07-20 15:39:51 -0700
committerGitHub <noreply@github.com>2023-07-20 15:39:51 -0700
commit0d79590340237214bccfca6a73ad11b3728f26fc (patch)
tree330e7f5bdf6c4c05a7cf8ba0aba2f6ec3a973976 /test
parent01f5eb8cf7d280e12985e628041ba57f9f8402d1 (diff)
downloadbinaryen-0d79590340237214bccfca6a73ad11b3728f26fc.tar.gz
binaryen-0d79590340237214bccfca6a73ad11b3728f26fc.tar.bz2
binaryen-0d79590340237214bccfca6a73ad11b3728f26fc.zip
Add support for debug printing of functions (#5828)
Diffstat (limited to 'test')
-rw-r--r--test/gtest/CMakeLists.txt1
-rw-r--r--test/gtest/printing.cpp44
2 files changed, 45 insertions, 0 deletions
diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt
index d3663bf63..f7824834a 100644
--- a/test/gtest/CMakeLists.txt
+++ b/test/gtest/CMakeLists.txt
@@ -5,6 +5,7 @@ set(unittest_SOURCES
cfg.cpp
dfa_minimization.cpp
possible-contents.cpp
+ printing.cpp
stringify.cpp
suffix_tree.cpp
type-builder.cpp
diff --git a/test/gtest/printing.cpp b/test/gtest/printing.cpp
new file mode 100644
index 000000000..312597886
--- /dev/null
+++ b/test/gtest/printing.cpp
@@ -0,0 +1,44 @@
+#include "print-test.h"
+
+#include "wasm.h"
+
+using namespace wasm;
+
+using PrintingTest = PrintTest;
+
+TEST_F(PrintingTest, Print) {
+ auto moduleText = R"wasm(
+ (module
+ (func $a (result i32)
+ (i32.const 10)
+ )
+ (func $b
+ (drop
+ (i32.const 20)
+ )
+ )
+ )
+ )wasm";
+
+ Module wasm;
+ parseWast(wasm, moduleText);
+
+ {
+ std::stringstream ss;
+ ss << *wasm.getFunction("a");
+ EXPECT_EQ(ss.str(), R"print((func $a (result i32)
+ (i32.const 10)
+)
+)print");
+ }
+ {
+ std::stringstream ss;
+ ss << *wasm.getFunction("b");
+ EXPECT_EQ(ss.str(), R"print((func $b
+ (drop
+ (i32.const 20)
+ )
+)
+)print");
+ }
+}