diff --git a/tests/Unifier2.test.cpp b/tests/Unifier2.test.cpp index 4810d077..8efb2870 100644 --- a/tests/Unifier2.test.cpp +++ b/tests/Unifier2.test.cpp @@ -132,67 +132,4 @@ TEST_CASE_FIXTURE(Unifier2Fixture, "unify_binds_free_supertype_tail_pack") CHECK("(number <: 'a)" == toString(freeAndFree)); } -TEST_CASE_FIXTURE(Unifier2Fixture, "generalize_a_type_that_is_bounded_by_another_generalizable_type") -{ - auto [t1, ft1] = freshType(); - auto [t2, ft2] = freshType(); - - // t2 <: t1 <: unknown - // unknown <: t2 <: t1 - - ft1->lowerBound = t2; - ft2->upperBound = t1; - ft2->lowerBound = builtinTypes.unknownType; - - auto t2generalized = u2.generalize(t2); - REQUIRE(t2generalized); - - CHECK(follow(t1) == follow(t2)); - - auto t1generalized = u2.generalize(t1); - REQUIRE(t1generalized); - - CHECK(builtinTypes.unknownType == follow(t1)); - CHECK(builtinTypes.unknownType == follow(t2)); -} - -// Same as generalize_a_type_that_is_bounded_by_another_generalizable_type -// except that we generalize the types in the opposite order -TEST_CASE_FIXTURE(Unifier2Fixture, "generalize_a_type_that_is_bounded_by_another_generalizable_type_in_reverse_order") -{ - auto [t1, ft1] = freshType(); - auto [t2, ft2] = freshType(); - - // t2 <: t1 <: unknown - // unknown <: t2 <: t1 - - ft1->lowerBound = t2; - ft2->upperBound = t1; - ft2->lowerBound = builtinTypes.unknownType; - - auto t1generalized = u2.generalize(t1); - REQUIRE(t1generalized); - - CHECK(follow(t1) == follow(t2)); - - auto t2generalized = u2.generalize(t2); - REQUIRE(t2generalized); - - CHECK(builtinTypes.unknownType == follow(t1)); - CHECK(builtinTypes.unknownType == follow(t2)); -} - -TEST_CASE_FIXTURE(Unifier2Fixture, "dont_traverse_into_class_types_when_generalizing") -{ - auto [propTy, _] = freshType(); - - TypeId cursedClass = arena.addType(ClassType{"Cursed", {{"oh_no", Property::readonly(propTy)}}, std::nullopt, std::nullopt, {}, {}, "", {}}); - - auto genClass = u2.generalize(cursedClass); - REQUIRE(genClass); - - auto genPropTy = get(*genClass)->props.at("oh_no").readTy; - CHECK(is(*genPropTy)); -} - TEST_SUITE_END();