diff options
author | Thomas Lively <tlively@google.com> | 2022-10-18 13:19:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 13:19:22 -0500 |
commit | 6bef18672fae68ee4976a7b26f277f6caa32734f (patch) | |
tree | e2198250c704715bbe968a0684c9dc79235fdffd /test/gtest | |
parent | 43c62ee5a1506535fcb67b84723264ac4cec008a (diff) | |
download | binaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.tar.gz binaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.tar.bz2 binaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.zip |
Implement `array` basic heap type (#5148)
`array` is the supertype of all defined array types and for now is a subtype of
`data`. (Once `data` becomes `struct` this will no longer be true.) Update the
binary and text parsing of `array.len` to ignore the obsolete type annotation
and update the binary emitting to emit a zero in place of the old type
annotation and the text printing to print an arbitrary heap type for the
annotation. A follow-on PR will add support for the newer unannotated version of
`array.len`.
Diffstat (limited to 'test/gtest')
-rw-r--r-- | test/gtest/type-builder.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index a397041bf..5760838da 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -506,6 +506,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { HeapType eq = HeapType::eq; HeapType i31 = HeapType::i31; HeapType data = HeapType::data; + HeapType array = HeapType::array; HeapType string = HeapType::string; HeapType stringview_wtf8 = HeapType::stringview_wtf8; HeapType stringview_wtf16 = HeapType::stringview_wtf16; @@ -551,6 +552,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(ext, eq, {}); assertLUB(ext, i31, {}); assertLUB(ext, data, {}); + assertLUB(ext, array, {}); assertLUB(ext, string, {}); assertLUB(ext, stringview_wtf8, {}); assertLUB(ext, stringview_wtf16, {}); @@ -567,6 +569,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(func, eq, {}); assertLUB(func, i31, {}); assertLUB(func, data, {}); + assertLUB(func, array, {}); assertLUB(func, string, {}); assertLUB(func, stringview_wtf8, {}); assertLUB(func, stringview_wtf16, {}); @@ -582,6 +585,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(any, eq, any); assertLUB(any, i31, any); assertLUB(any, data, any); + assertLUB(any, array, any); assertLUB(any, string, any); assertLUB(any, stringview_wtf8, any); assertLUB(any, stringview_wtf16, any); @@ -596,6 +600,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(eq, eq, eq); assertLUB(eq, i31, eq); assertLUB(eq, data, eq); + assertLUB(eq, array, eq); assertLUB(eq, string, any); assertLUB(eq, stringview_wtf8, any); assertLUB(eq, stringview_wtf16, any); @@ -609,6 +614,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(i31, i31, i31); assertLUB(i31, data, eq); + assertLUB(i31, array, eq); assertLUB(i31, string, any); assertLUB(i31, stringview_wtf8, any); assertLUB(i31, stringview_wtf16, any); @@ -621,6 +627,7 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(i31, defArray, eq); assertLUB(data, data, data); + assertLUB(data, array, data); assertLUB(data, string, any); assertLUB(data, stringview_wtf8, any); assertLUB(data, stringview_wtf16, any); @@ -632,6 +639,18 @@ TEST_F(IsorecursiveTest, TestBasicTypeRelations) { assertLUB(data, defStruct, data); assertLUB(data, defArray, data); + assertLUB(array, array, array); + assertLUB(array, string, any); + assertLUB(array, stringview_wtf8, any); + assertLUB(array, stringview_wtf16, any); + assertLUB(array, stringview_iter, any); + assertLUB(array, none, array); + assertLUB(array, noext, {}); + assertLUB(array, nofunc, {}); + assertLUB(array, defFunc, {}); + assertLUB(array, defStruct, data); + assertLUB(array, defArray, array); + assertLUB(string, string, string); assertLUB(string, stringview_wtf8, any); assertLUB(string, stringview_wtf16, any); @@ -865,13 +884,14 @@ TEST_F(NominalTest, TestDepth) { C = built[2]; } - // any < eq < data < specific struct and array types + // any :> eq :> data :> array :> specific array types EXPECT_EQ(HeapType(HeapType::any).getDepth(), 0U); EXPECT_EQ(HeapType(HeapType::eq).getDepth(), 1U); EXPECT_EQ(HeapType(HeapType::data).getDepth(), 2U); + EXPECT_EQ(HeapType(HeapType::array).getDepth(), 3U); EXPECT_EQ(A.getDepth(), 3U); EXPECT_EQ(B.getDepth(), 4U); - EXPECT_EQ(C.getDepth(), 3U); + EXPECT_EQ(C.getDepth(), 4U); // Signature types are subtypes of func. EXPECT_EQ(HeapType(HeapType::func).getDepth(), 0U); |