mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 14:59:05 +00:00
test(swift): reuse witness table fixture maps (#16055)
This commit is contained in:
1 parent
995f1243e3
commit
cadaa428b8
1 file changed
+37
-63
@@ -321,17 +321,42 @@ it("counts examined slots and reports an unresolved async slot", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a located issue for an emitted unresolved witness slot", () => {
|
||||
const result = objcSwiftMetadataSchema.parse({ db_save_result: null });
|
||||
const witnessFixture = (
|
||||
flags: number,
|
||||
typeReference: bigint,
|
||||
witnessRequirement?: number,
|
||||
) => {
|
||||
const values = new Map<bigint, number>([
|
||||
[0x20cn, 0], // simple, unconditional conformance
|
||||
[0x20cn, flags],
|
||||
[0x500n, 3], // protocol descriptor kind
|
||||
[0x800n, 0], // module context
|
||||
[0x50cn, 0], // signature count
|
||||
[0x510n, 1], // witness requirement count
|
||||
[0x2b0n, 16], // nominal type descriptor kind
|
||||
[0x518n, 1], // function witness requirement
|
||||
]);
|
||||
if (witnessRequirement !== undefined) values.set(0x518n, witnessRequirement);
|
||||
const targets = new Map<bigint, bigint>([
|
||||
[0x100n, 0x200n],
|
||||
[0x200n, 0x500n],
|
||||
[0x508n, 0x600n],
|
||||
[0x504n, 0x800n],
|
||||
[0x808n, 0x820n],
|
||||
[0x204n, typeReference],
|
||||
[0x2b8n, 0x700n],
|
||||
[0x208n, 0x380n],
|
||||
]);
|
||||
return {
|
||||
values,
|
||||
relative: (field: bigint) => ({
|
||||
kind: "target" as const,
|
||||
target: targets.get(field) ?? 0n,
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
it("returns a located issue for an emitted unresolved witness slot", () => {
|
||||
const result = objcSwiftMetadataSchema.parse({ db_save_result: null });
|
||||
const { values, relative } = witnessFixture(0, 0x2b0n, 1);
|
||||
const budget: DispatchRecordBudget = {
|
||||
truncated: false,
|
||||
isFull: () => false,
|
||||
@@ -357,20 +382,8 @@ it("returns a located issue for an emitted unresolved witness slot", () => {
|
||||
evidence: swiftFixtureEvidence,
|
||||
offset: (address) => Number(address),
|
||||
},
|
||||
relative: (field) => ({
|
||||
kind: "target",
|
||||
target:
|
||||
new Map<bigint, bigint>([
|
||||
[0x100n, 0x200n],
|
||||
[0x200n, 0x500n],
|
||||
[0x508n, 0x600n],
|
||||
[0x504n, 0x800n],
|
||||
[0x808n, 0x820n],
|
||||
[0x204n, 0x2b0n],
|
||||
[0x2b8n, 0x700n],
|
||||
[0x208n, 0x380n],
|
||||
]).get(field) ?? 0n,
|
||||
}),
|
||||
relative,
|
||||
|
||||
budget,
|
||||
result,
|
||||
});
|
||||
@@ -385,15 +398,7 @@ it("returns a located issue for an emitted unresolved witness slot", () => {
|
||||
|
||||
it("decodes a retroactive static witness slot when flags include retroactive bit 0x40", () => {
|
||||
const result = objcSwiftMetadataSchema.parse({ db_save_result: null });
|
||||
const values = new Map<bigint, number>([
|
||||
[0x20cn, 0x48], // kind 1 (0x08) + retroactive conformance (0x40)
|
||||
[0x500n, 3], // protocol descriptor kind
|
||||
[0x800n, 0], // module context
|
||||
[0x50cn, 0], // signature count
|
||||
[0x510n, 1], // witness requirement count
|
||||
[0x2b0n, 16], // nominal type descriptor kind
|
||||
[0x518n, 1], // synchronous function witness requirement
|
||||
]);
|
||||
const { values, relative } = witnessFixture(0x48, 0x2a0n, 1);
|
||||
const budget: DispatchRecordBudget = {
|
||||
truncated: false,
|
||||
isFull: () => false,
|
||||
@@ -427,20 +432,8 @@ it("decodes a retroactive static witness slot when flags include retroactive bit
|
||||
evidence: swiftFixtureEvidence,
|
||||
offset: (address) => Number(address),
|
||||
},
|
||||
relative: (field) => ({
|
||||
kind: "target",
|
||||
target:
|
||||
new Map<bigint, bigint>([
|
||||
[0x100n, 0x200n],
|
||||
[0x200n, 0x500n],
|
||||
[0x508n, 0x600n],
|
||||
[0x504n, 0x800n],
|
||||
[0x808n, 0x820n],
|
||||
[0x204n, 0x2a0n], // indirect pointer to type descriptor
|
||||
[0x2b8n, 0x700n],
|
||||
[0x208n, 0x380n],
|
||||
]).get(field) ?? 0n,
|
||||
}),
|
||||
relative,
|
||||
|
||||
budget,
|
||||
result,
|
||||
});
|
||||
@@ -467,14 +460,7 @@ it("decodes a retroactive static witness slot when flags include retroactive bit
|
||||
|
||||
it("retains partial coverage for retroactive conformance when conditional requirement flags are set", () => {
|
||||
const result = objcSwiftMetadataSchema.parse({ db_save_result: null });
|
||||
const values = new Map<bigint, number>([
|
||||
[0x20cn, 0x148], // kind 1 (0x08) + retroactive (0x40) + conditional requirements (0x100)
|
||||
[0x500n, 3], // protocol descriptor kind
|
||||
[0x800n, 0], // module context
|
||||
[0x50cn, 0], // signature count
|
||||
[0x510n, 1], // witness requirement count
|
||||
[0x2b0n, 16], // nominal type descriptor kind
|
||||
]);
|
||||
const { values, relative } = witnessFixture(0x148, 0x2a0n);
|
||||
const budget: DispatchRecordBudget = {
|
||||
truncated: false,
|
||||
isFull: () => false,
|
||||
@@ -498,20 +484,8 @@ it("retains partial coverage for retroactive conformance when conditional requir
|
||||
evidence: swiftFixtureEvidence,
|
||||
offset: (address) => Number(address),
|
||||
},
|
||||
relative: (field) => ({
|
||||
kind: "target",
|
||||
target:
|
||||
new Map<bigint, bigint>([
|
||||
[0x100n, 0x200n],
|
||||
[0x200n, 0x500n],
|
||||
[0x508n, 0x600n],
|
||||
[0x504n, 0x800n],
|
||||
[0x808n, 0x820n],
|
||||
[0x204n, 0x2a0n],
|
||||
[0x2b8n, 0x700n],
|
||||
[0x208n, 0x380n],
|
||||
]).get(field) ?? 0n,
|
||||
}),
|
||||
relative,
|
||||
|
||||
budget,
|
||||
result,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user