summaryrefslogtreecommitdiff
path: root/test/gtest/printing.cpp
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/gtest/printing.cpp
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/gtest/printing.cpp')
-rw-r--r--test/gtest/printing.cpp44
1 files changed, 44 insertions, 0 deletions
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");
+ }
+}