Skip to content

Commit 0b053dd

Browse files
committed
Update runtime test for witness table layout change
1 parent e614f66 commit 0b053dd

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

Diff for: unittests/runtime/Metadata.cpp

+25-24
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,11 @@ static void witnessTableInstantiator(WitnessTable *instantiatedTable,
906906
void * const *instantiationArgs) {
907907
EXPECT_EQ(type, nullptr);
908908

909-
EXPECT_EQ(((void **) instantiatedTable)[0], (void*) 123);
910-
EXPECT_EQ(((void **) instantiatedTable)[1], (void*) 234);
909+
EXPECT_EQ(((void **) instantiatedTable)[1], (void*) 123);
910+
EXPECT_EQ(((void **) instantiatedTable)[2], (void*) 234);
911911

912912
// The last witness is computed dynamically at instantiation time.
913-
((void **) instantiatedTable)[2] = (void *) 345;
913+
((void **) instantiatedTable)[3] = (void *) 345;
914914

915915
auto conditionalTables =
916916
reinterpret_cast<const WitnessTableSlice *>(instantiationArgs);
@@ -937,8 +937,8 @@ struct TestProtocol {
937937
: descriptor("TestProtocol",
938938
nullptr,
939939
ProtocolDescriptorFlags().withResilient(true)) {
940-
descriptor.NumMandatoryRequirements = 3;
941-
descriptor.NumRequirements = 5;
940+
descriptor.NumMandatoryRequirements = 4;
941+
descriptor.NumRequirements = 6;
942942
initializeRelativePointer(
943943
(int32_t *) &descriptor.Requirements,
944944
requirements);
@@ -975,6 +975,7 @@ GenericWitnessTable::PrivateDataType tablePrivateData3;
975975
GenericWitnessTable::PrivateDataType tablePrivateData4;
976976

977977
const void *witnesses[] = {
978+
(void *) 0, // protocol descriptor
978979
(void *) 123,
979980
(void *) 234,
980981
(void *) 0, // filled in by instantiator function
@@ -996,7 +997,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
996997
// Conformance provides all requirements, and we don't have an
997998
// instantiator, so we can just return the pattern.
998999
{
999-
tableStorage1.WitnessTableSizeInWords = 5;
1000+
tableStorage1.WitnessTableSizeInWords = 6;
10001001
tableStorage1.WitnessTablePrivateSizeInWords = 0;
10011002
initializeRelativePointer(&tableStorage1.Protocol, &testProtocol.descriptor);
10021003
initializeRelativePointer(&tableStorage1.Pattern, witnesses);
@@ -1019,7 +1020,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
10191020
// Conformance provides all requirements, but we have private storage
10201021
// and an initializer, so we must instantiate.
10211022
{
1022-
tableStorage2.WitnessTableSizeInWords = 5;
1023+
tableStorage2.WitnessTableSizeInWords = 6;
10231024
tableStorage2.WitnessTablePrivateSizeInWords = 1 + 1;
10241025
initializeRelativePointer(&tableStorage2.Protocol, &testProtocol.descriptor);
10251026
initializeRelativePointer(&tableStorage2.Pattern, witnesses);
@@ -1042,15 +1043,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
10421043
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[-1],
10431044
reinterpret_cast<void *>(678));
10441045

1045-
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[0],
1046-
reinterpret_cast<void *>(123));
10471046
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[1],
1048-
reinterpret_cast<void *>(234));
1047+
reinterpret_cast<void *>(123));
10491048
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[2],
1050-
reinterpret_cast<void *>(345));
1049+
reinterpret_cast<void *>(234));
10511050
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[3],
1052-
reinterpret_cast<void *>(456));
1051+
reinterpret_cast<void *>(345));
10531052
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[4],
1053+
reinterpret_cast<void *>(456));
1054+
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[5],
10541055
reinterpret_cast<void *>(567));
10551056

10561057
return instantiatedTable;
@@ -1059,7 +1060,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
10591060

10601061
// Conformance needs one default requirement to be filled in
10611062
{
1062-
tableStorage3.WitnessTableSizeInWords = 4;
1063+
tableStorage3.WitnessTableSizeInWords = 5;
10631064
tableStorage3.WitnessTablePrivateSizeInWords = 1 + 1;
10641065
initializeRelativePointer(&tableStorage3.Protocol, &testProtocol.descriptor);
10651066
initializeRelativePointer(&tableStorage3.Pattern, witnesses);
@@ -1081,15 +1082,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
10811082
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[-1],
10821083
reinterpret_cast<void *>(678));
10831084

1084-
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[0],
1085-
reinterpret_cast<void *>(123));
10861085
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[1],
1087-
reinterpret_cast<void *>(234));
1086+
reinterpret_cast<void *>(123));
10881087
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[2],
1089-
reinterpret_cast<void *>(345));
1088+
reinterpret_cast<void *>(234));
10901089
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[3],
1091-
reinterpret_cast<void *>(456));
1090+
reinterpret_cast<void *>(345));
10921091
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[4],
1092+
reinterpret_cast<void *>(456));
1093+
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[5],
10931094
reinterpret_cast<void *>(fakeDefaultWitness2));
10941095

10951096
return instantiatedTable;
@@ -1099,7 +1100,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
10991100
// Third case: conformance needs both default requirements
11001101
// to be filled in
11011102
{
1102-
tableStorage4.WitnessTableSizeInWords = 3;
1103+
tableStorage4.WitnessTableSizeInWords = 4;
11031104
tableStorage4.WitnessTablePrivateSizeInWords = 1 + 1;
11041105
initializeRelativePointer(&tableStorage4.Protocol, &testProtocol.descriptor);
11051106
initializeRelativePointer(&tableStorage4.Pattern, witnesses);
@@ -1121,15 +1122,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
11211122
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[-1],
11221123
reinterpret_cast<void *>(678));
11231124

1124-
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[0],
1125-
reinterpret_cast<void *>(123));
11261125
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[1],
1127-
reinterpret_cast<void *>(234));
1126+
reinterpret_cast<void *>(123));
11281127
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[2],
1129-
reinterpret_cast<void *>(345));
1128+
reinterpret_cast<void *>(234));
11301129
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[3],
1131-
reinterpret_cast<void *>(fakeDefaultWitness1));
1130+
reinterpret_cast<void *>(345));
11321131
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[4],
1132+
reinterpret_cast<void *>(fakeDefaultWitness1));
1133+
EXPECT_EQ(reinterpret_cast<void * const *>(instantiatedTable)[5],
11331134
reinterpret_cast<void *>(fakeDefaultWitness2));
11341135

11351136
return instantiatedTable;

0 commit comments

Comments
 (0)