summaryrefslogtreecommitdiff
path: root/test/gtest/possible-contents.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-08-22 16:21:19 -0700
committerGitHub <noreply@github.com>2022-08-22 16:21:19 -0700
commit92cdc7245b715d88cf986a7eaf78c49ea64ba825 (patch)
tree7e20e91c0a60a5b08f8bb01d64ea7ebc3a6b6885 /test/gtest/possible-contents.cpp
parent195c4e1804d5a4530c8216d4c9a138b56f676d10 (diff)
downloadbinaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.tar.gz
binaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.tar.bz2
binaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.zip
Separate `func` into a separate type hierarchy (#4955)
Just like `extern` is no longer a subtype of `any` in the new GC type system, `func` is no longer a subtype of `any`, either. Make that change in our type system implementation and update tests and fuzzers accordingly.
Diffstat (limited to 'test/gtest/possible-contents.cpp')
-rw-r--r--test/gtest/possible-contents.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp
index 90c6cac51..27ab5b8fb 100644
--- a/test/gtest/possible-contents.cpp
+++ b/test/gtest/possible-contents.cpp
@@ -65,6 +65,7 @@ protected:
Type anyref = Type(HeapType::any, Nullable);
Type funcref = Type(HeapType::func, Nullable);
+ Type i31ref = Type(HeapType::i31, Nullable);
PossibleContents none = PossibleContents::none();
@@ -75,6 +76,8 @@ protected:
PossibleContents::literal(Literal::makeNull(HeapType::any));
PossibleContents funcNull =
PossibleContents::literal(Literal::makeNull(HeapType::func));
+ PossibleContents i31Null =
+ PossibleContents::literal(Literal::makeNull(HeapType::i31));
PossibleContents i32Global1 =
PossibleContents::global("i32Global1", Type::i32);
@@ -89,10 +92,13 @@ protected:
PossibleContents exactI32 = PossibleContents::exactType(Type::i32);
PossibleContents exactAnyref = PossibleContents::exactType(anyref);
PossibleContents exactFuncref = PossibleContents::exactType(funcref);
+ PossibleContents exactI31ref = PossibleContents::exactType(i31ref);
PossibleContents exactNonNullAnyref =
PossibleContents::exactType(Type(HeapType::any, NonNullable));
PossibleContents exactNonNullFuncref =
PossibleContents::exactType(Type(HeapType::func, NonNullable));
+ PossibleContents exactNonNullI31ref =
+ PossibleContents::exactType(Type(HeapType::i31, NonNullable));
PossibleContents exactFuncSignatureType = PossibleContents::exactType(
Type(Signature(Type::none, Type::none), Nullable));
@@ -183,7 +189,10 @@ TEST_F(PossibleContentsTest, TestCombinations) {
assertCombination(anyNull, exactAnyref, exactAnyref);
// Two nulls go to the lub.
- assertCombination(anyNull, funcNull, anyNull);
+ assertCombination(anyNull, i31Null, anyNull);
+
+ // Incompatible nulls go to Many.
+ assertCombination(anyNull, funcNull, many);
assertCombination(exactNonNullAnyref, exactNonNullAnyref, exactNonNullAnyref);
@@ -191,13 +200,12 @@ TEST_F(PossibleContentsTest, TestCombinations) {
// null be a nullable type - but keeps the heap type of the other (since the
// type of the null does not matter, all nulls compare equal).
assertCombination(anyNull, exactNonNullAnyref, exactAnyref);
- assertCombination(anyNull, exactNonNullFuncref, exactFuncref);
+ assertCombination(anyNull, exactNonNullI31ref, exactI31ref);
// Funcrefs
// A function reference + a null becomes an exact type (of that sig), plus
// nullability.
- assertCombination(nonNullFunc, anyNull, exactFuncSignatureType);
assertCombination(nonNullFunc, funcNull, exactFuncSignatureType);
assertCombination(exactFuncSignatureType, funcNull, exactFuncSignatureType);
assertCombination(
@@ -211,7 +219,7 @@ TEST_F(PossibleContentsTest, TestCombinations) {
// Globals vs nulls.
assertCombination(anyGlobal, anyNull, many);
- assertCombination(anyGlobal, funcNull, many);
+ assertCombination(anyGlobal, i31Null, many);
}
TEST_F(PossibleContentsTest, TestOracleMinimal) {