[Runtime] Update unit test for swift_getAssociated(Type|Conformance)Slow.

This commit is contained in:
Doug Gregor
2018-11-15 09:57:36 -08:00
parent dc73c67d10
commit 75947627cf

View File

@@ -24,6 +24,17 @@ using namespace swift;
bool EnableOverride;
bool Ran;
namespace {
template<typename T>
T getEmptyValue() {
return (T)0;
}
template<>
MetadataResponse getEmptyValue<MetadataResponse>() {
return MetadataResponse{nullptr, MetadataState::Complete};
}
}
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
static ret name ## Override(COMPATIBILITY_UNPAREN typedArgs, \
@@ -31,7 +42,7 @@ bool Ran;
if (!EnableOverride) \
return originalImpl namedArgs; \
Ran = true; \
return (ret)0; \
return getEmptyValue<ret>(); \
}
#include "../../stdlib/public/runtime/CompatibilityOverride.def"
@@ -164,4 +175,20 @@ TEST_F(CompatibilityOverrideTest, test_swift_conformsToProtocol) {
ASSERT_EQ(Result, nullptr);
}
TEST_F(CompatibilityOverrideTest, test_swift_getAssociatedTypeWitnessSlow) {
auto Result = swift_getAssociatedTypeWitnessSlow(MetadataState::Complete,
nullptr, nullptr,
nullptr, nullptr);
ASSERT_EQ(Result.Value, nullptr);
ASSERT_EQ(Result.State, MetadataState::Complete);
}
TEST_F(CompatibilityOverrideTest,
test_swift_getAssociatedConformanceWitnessSlow) {
auto Result = swift_getAssociatedConformanceWitnessSlow(
nullptr, nullptr, nullptr,
nullptr, nullptr);
ASSERT_EQ(Result, nullptr);
}
#endif