summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-02-26 17:28:27 -0800
committerGitHub <noreply@github.com>2021-02-26 17:28:27 -0800
commita276c7e9687a98bb4cb222c71278a8658633d80f (patch)
treeb9d1cbe3ade5520f99ad9b74b4195f9bad3d5259 /test
parent1ba4d259616a71a6a80662f1dff95fc125ecac2e (diff)
downloadbinaryen-a276c7e9687a98bb4cb222c71278a8658633d80f.tar.gz
binaryen-a276c7e9687a98bb4cb222c71278a8658633d80f.tar.bz2
binaryen-a276c7e9687a98bb4cb222c71278a8658633d80f.zip
Support printing recursive types (#3624)
Also fixes a few locations in Print.cpp where types were being printed directly rather than going through the s-expression type printer and removes vestigial wrapper types that were no longer used.
Diffstat (limited to 'test')
-rw-r--r--test/example/type-builder.cpp14
-rw-r--r--test/example/type-builder.txt18
2 files changed, 32 insertions, 0 deletions
diff --git a/test/example/type-builder.cpp b/test/example/type-builder.cpp
index 8503c037b..59222775b 100644
--- a/test/example/type-builder.cpp
+++ b/test/example/type-builder.cpp
@@ -112,6 +112,7 @@ void test_recursive() {
builder.setHeapType(0, Signature(Type::none, temp));
built = builder.build();
}
+ std::cout << built[0] << "\n\n";
assert(built[0] == built[0].getSignature().results.getHeapType());
assert(Type(built[0], Nullable) == built[0].getSignature().results);
}
@@ -127,6 +128,8 @@ void test_recursive() {
builder.setHeapType(1, Signature(Type::none, temp0));
built = builder.build();
}
+ std::cout << built[0] << "\n";
+ std::cout << built[1] << "\n\n";
assert(built[0].getSignature().results.getHeapType() == built[1]);
assert(built[1].getSignature().results.getHeapType() == built[0]);
}
@@ -148,6 +151,11 @@ void test_recursive() {
builder.setHeapType(4, Signature(Type::none, temp0));
built = builder.build();
}
+ std::cout << built[0] << "\n";
+ std::cout << built[1] << "\n";
+ std::cout << built[2] << "\n";
+ std::cout << built[3] << "\n";
+ std::cout << built[4] << "\n\n";
assert(built[0].getSignature().results.getHeapType() == built[1]);
assert(built[1].getSignature().results.getHeapType() == built[2]);
assert(built[2].getSignature().results.getHeapType() == built[3]);
@@ -175,6 +183,12 @@ void test_recursive() {
builder.setHeapType(5, Signature(Type::none, temp1));
built = builder.build();
}
+ std::cout << built[0] << "\n";
+ std::cout << built[1] << "\n";
+ std::cout << built[2] << "\n";
+ std::cout << built[3] << "\n";
+ std::cout << built[4] << "\n";
+ std::cout << built[5] << "\n\n";
assert(built[0] != built[1]); // TODO: canonicalize recursive types
assert(built[2] == built[3]);
assert(built[4] != built[5]); // Contain "different" recursive types
diff --git a/test/example/type-builder.txt b/test/example/type-builder.txt
index 0cb414be1..6b42ade8c 100644
--- a/test/example/type-builder.txt
+++ b/test/example/type-builder.txt
@@ -22,3 +22,21 @@ After building types:
;; Test canonicalization
;; Test recursive types
+(func (result (ref null ...1)))
+
+(func (result (ref null (func (result (ref null ...3))))))
+(func (result (ref null (func (result (ref null ...3))))))
+
+(func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null ...9)))))))))))))))
+(func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null ...9)))))))))))))))
+(func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null ...9)))))))))))))))
+(func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null ...9)))))))))))))))
+(func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null (func (result (ref null ...9)))))))))))))))
+
+(func (result (ref null ...1) (ref null (func))))
+(func (result (ref null ...1) (ref null (func))))
+(func)
+(func)
+(func (result (ref null (func (result ...1 (ref null (func)))))))
+(func (result (ref null (func (result ...1 (ref null (func)))))))
+