diff options
Diffstat (limited to 'test/example')
-rw-r--r-- | test/example/stack-utils.cpp | 21 | ||||
-rw-r--r-- | test/example/type-builder-nominal.cpp | 7 | ||||
-rw-r--r-- | test/example/type-builder.cpp | 36 |
3 files changed, 32 insertions, 32 deletions
diff --git a/test/example/stack-utils.cpp b/test/example/stack-utils.cpp index c54040251..f8824e5cb 100644 --- a/test/example/stack-utils.cpp +++ b/test/example/stack-utils.cpp @@ -250,7 +250,7 @@ void test_signature_composition() { } void test_signature_subtype() { - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); Type anyref = Type(HeapType::any, Nullable); std::cout << ";; Test stack signature subtyping\n"; @@ -263,7 +263,7 @@ void test_signature_subtype() { } // Covariance of results { - StackSignature a(Type::none, funcref, StackSignature::Fixed); + StackSignature a(Type::none, eqref, StackSignature::Fixed); StackSignature b(Type::none, anyref, StackSignature::Fixed); assert(StackSignature::isSubType(a, b)); assert(!StackSignature::isSubType(b, a)); @@ -271,7 +271,7 @@ void test_signature_subtype() { // Contravariance of params { StackSignature a(anyref, Type::none, StackSignature::Fixed); - StackSignature b(funcref, Type::none, StackSignature::Fixed); + StackSignature b(eqref, Type::none, StackSignature::Fixed); assert(StackSignature::isSubType(a, b)); assert(!StackSignature::isSubType(b, a)); } @@ -358,7 +358,7 @@ void test_signature_subtype() { } void test_signature_lub() { - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); Type anyref = Type(HeapType::any, Nullable); std::cout << ";; Test stack signature lub\n"; @@ -399,26 +399,25 @@ void test_signature_lub() { } { StackSignature a{Type::none, anyref, StackSignature::Polymorphic}; - StackSignature b{Type::none, funcref, StackSignature::Polymorphic}; + StackSignature b{Type::none, eqref, StackSignature::Polymorphic}; assert(StackSignature::haveLeastUpperBound(a, b)); assert(StackSignature::getLeastUpperBound(a, b) == (StackSignature{Type::none, anyref, StackSignature::Polymorphic})); } { StackSignature a{anyref, Type::none, StackSignature::Polymorphic}; - StackSignature b{funcref, Type::none, StackSignature::Polymorphic}; + StackSignature b{eqref, Type::none, StackSignature::Polymorphic}; // assert(StackSignature::haveLeastUpperBound(a, b)); // assert(StackSignature::getLeastUpperBound(a, b) == - // (StackSignature{funcref, Type::none, + // (StackSignature{eqref, Type::none, // StackSignature::Polymorphic})); } { - StackSignature a{ - {Type::i32, funcref}, funcref, StackSignature::Polymorphic}; - StackSignature b{funcref, {Type::f32, anyref}, StackSignature::Polymorphic}; + StackSignature a{{Type::i32, eqref}, eqref, StackSignature::Polymorphic}; + StackSignature b{eqref, {Type::f32, anyref}, StackSignature::Polymorphic}; assert(StackSignature::haveLeastUpperBound(a, b)); assert(StackSignature::getLeastUpperBound(a, b) == - (StackSignature{{Type::i32, funcref}, + (StackSignature{{Type::i32, eqref}, {Type::f32, anyref}, StackSignature::Polymorphic})); } diff --git a/test/example/type-builder-nominal.cpp b/test/example/type-builder-nominal.cpp index 13224f55e..66dccead3 100644 --- a/test/example/type-builder-nominal.cpp +++ b/test/example/type-builder-nominal.cpp @@ -307,7 +307,7 @@ void test_subtypes() { std::cout << ";; Test subtyping\n"; Type anyref = Type(HeapType::any, Nullable); - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); auto LUB = [&](HeapType a, HeapType b) { Type refA = Type(a, Nullable); @@ -330,14 +330,13 @@ void test_subtypes() { { // Basic Types - for (auto other : {HeapType::func, + for (auto other : {HeapType::eq, HeapType::any, HeapType::eq, HeapType::i31, HeapType::data}) { assert(LUB(HeapType::any, other) == HeapType::any); } - assert(LUB(HeapType::eq, HeapType::func) == HeapType::any); assert(LUB(HeapType::i31, HeapType::data) == HeapType::eq); } @@ -430,7 +429,7 @@ void test_subtypes() { { TypeBuilder builder(2); builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(funcref, Immutable)}); + builder[1] = Struct({Field(eqref, Immutable)}); builder[1].subTypeOf(builder[0]); built = *builder.build(); } diff --git a/test/example/type-builder.cpp b/test/example/type-builder.cpp index 41c556878..7da2f8f03 100644 --- a/test/example/type-builder.cpp +++ b/test/example/type-builder.cpp @@ -223,6 +223,7 @@ void test_recursive() { void test_lub() { std::cout << ";; Test LUBs\n"; + Type ext = Type(HeapType::ext, Nullable); Type func = Type(HeapType::func, Nullable); Type any = Type(HeapType::any, Nullable); Type eq = Type(HeapType::eq, Nullable); @@ -247,10 +248,11 @@ void test_lub() { { // Basic Types - for (auto other : {func, any, eq, i31, data}) { + for (auto other : {any, eq, i31, data}) { assert(LUB(any, other) == any); + assert(LUB(func, other) == Type::none); + assert(LUB(ext, other) == Type::none); } - assert(LUB(eq, func) == any); assert(LUB(i31, data) == eq); } @@ -314,17 +316,17 @@ void test_lub() { { // Immutable fields are covariant - Type a(Array(Field(eq, Immutable)), Nullable); - Type b(Array(Field(func, Immutable)), Nullable); - Type lub(Array(Field(any, Immutable)), Nullable); + Type a(Array(Field(data, Immutable)), Nullable); + Type b(Array(Field(i31, Immutable)), Nullable); + Type lub(Array(Field(eq, Immutable)), Nullable); assert(LUB(a, b) == lub); } { // Depth subtyping - Type a(Struct({Field(eq, Immutable)}), Nullable); - Type b(Struct({Field(func, Immutable)}), Nullable); - Type lub(Struct({Field(any, Immutable)}), Nullable); + Type a(Struct({Field(data, Immutable)}), Nullable); + Type b(Struct({Field(i31, Immutable)}), Nullable); + Type lub(Struct({Field(eq, Immutable)}), Nullable); assert(LUB(a, b) == lub); } @@ -348,11 +350,11 @@ void test_lub() { { // Width and depth subtyping with different suffixes - Type a(Struct({Field(eq, Immutable), Field(Type::i64, Immutable)}), + Type a(Struct({Field(data, Immutable), Field(Type::i64, Immutable)}), Nullable); - Type b(Struct({Field(func, Immutable), Field(Type::f32, Immutable)}), + Type b(Struct({Field(i31, Immutable), Field(Type::f32, Immutable)}), Nullable); - Type lub(Struct({Field(any, Immutable)}), Nullable); + Type lub(Struct({Field(eq, Immutable)}), Nullable); assert(LUB(a, b) == lub); } @@ -368,9 +370,9 @@ void test_lub() { { // Nested structs - Type innerA(Struct({Field(eq, Immutable)}), Nullable); - Type innerB(Struct({Field(func, Immutable)}), Nullable); - Type innerLub(Struct({Field(any, Immutable)}), Nullable); + Type innerA(Struct({Field(data, Immutable)}), Nullable); + Type innerB(Struct({Field(i31, Immutable)}), Nullable); + Type innerLub(Struct({Field(eq, Immutable)}), Nullable); Type a(Struct({Field(innerA, Immutable)}), Nullable); Type b(Struct({Field(innerB, Immutable)}), Nullable); Type lub(Struct({Field(innerLub, Immutable)}), Nullable); @@ -382,15 +384,15 @@ void test_lub() { TypeBuilder builder(2); Type tempA = builder.getTempRefType(builder[0], Nullable); Type tempB = builder.getTempRefType(builder[1], Nullable); - builder[0] = Struct({Field(tempB, Immutable), Field(eq, Immutable)}); - builder[1] = Struct({Field(tempA, Immutable), Field(func, Immutable)}); + builder[0] = Struct({Field(tempB, Immutable), Field(data, Immutable)}); + builder[1] = Struct({Field(tempA, Immutable), Field(i31, Immutable)}); auto built = *builder.build(); Type a(built[0], Nullable); Type b(built[1], Nullable); TypeBuilder lubBuilder(1); Type tempLub = builder.getTempRefType(lubBuilder[0], Nullable); - lubBuilder[0] = Struct({Field(tempLub, Immutable), Field(any, Immutable)}); + lubBuilder[0] = Struct({Field(tempLub, Immutable), Field(eq, Immutable)}); built = *lubBuilder.build(); Type lub(built[0], Nullable); |