summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-01-28 17:56:12 -0800
committerGitHub <noreply@github.com>2022-01-29 01:56:12 +0000
commit098e02abadefe0e227c3c88a36e93d083ce004a8 (patch)
tree8e04edb91b4d57f9776c86169c8cbf0f12b7b8c5 /test
parent019df9d734b463ad4d194f4241c5e4f077e07def (diff)
downloadbinaryen-098e02abadefe0e227c3c88a36e93d083ce004a8.tar.gz
binaryen-098e02abadefe0e227c3c88a36e93d083ce004a8.tar.bz2
binaryen-098e02abadefe0e227c3c88a36e93d083ce004a8.zip
Isorecursive HeapType constructors (#4482)
Update the HeapType constructors that take Signature, Structs, and Arrays to work properly with isorecursive typing. This is particularly important for the Signature constructor, which is used frequently throughout the code base.
Diffstat (limited to 'test')
-rw-r--r--test/gtest/type-builder.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp
index 8f922380d..b6ed40262 100644
--- a/test/gtest/type-builder.cpp
+++ b/test/gtest/type-builder.cpp
@@ -402,3 +402,32 @@ TEST_F(IsorecursiveTest, CanonicalizeSupertypes) {
EXPECT_NE(built[3], built[5]);
EXPECT_NE(built[4], built[5]);
}
+
+TEST_F(IsorecursiveTest, HeapTypeConstructors) {
+ HeapType sig(Signature(Type::i32, Type::i32));
+ HeapType struct_(Struct({Field(Type(sig, Nullable), Mutable)}));
+ HeapType array(Field(Type(struct_, Nullable), Mutable));
+
+ TypeBuilder builder(3);
+ builder[0] = Signature(Type::i32, Type::i32);
+ Type sigRef = builder.getTempRefType(builder[0], Nullable);
+ builder[1] = Struct({Field(sigRef, Mutable)});
+ Type structRef = builder.getTempRefType(builder[1], Nullable);
+ builder[2] = Array(Field(structRef, Mutable));
+
+ auto result = builder.build();
+ ASSERT_TRUE(result);
+ auto built = *result;
+
+ EXPECT_EQ(built[0], sig);
+ EXPECT_EQ(built[1], struct_);
+ EXPECT_EQ(built[2], array);
+
+ HeapType sig2(Signature(Type::i32, Type::i32));
+ HeapType struct2(Struct({Field(Type(sig, Nullable), Mutable)}));
+ HeapType array2(Field(Type(struct_, Nullable), Mutable));
+
+ EXPECT_EQ(sig, sig2);
+ EXPECT_EQ(struct_, struct2);
+ EXPECT_EQ(array, array2);
+}