test(conformance): share invalid fixture expectation pairs (#16650)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 16:01:25 +08:00
1 parent b0f4e8b961
commit 38dfd56d13
1 file changed
+23 -49
@@ -36,7 +36,20 @@ for (const [prefix, count] of [
] as const) {
const unpaired = `must carry ${prefix} and ${count} together`;
const invalid = `Invalid conformance fixture ${prefix}/${count} expectation`;
it.each([
const invalidPair = (
name: string,
prefixValue: unknown,
countValue: unknown,
) => ({
name,
expectation: { [prefix]: prefixValue, [count]: countValue },
failure: invalid,
});
it.each<{
name: string;
expectation: Record<string, unknown>;
failure?: string;
}>([
{ name: "omitted", expectation: {} },
{
name: "zero",
@@ -56,54 +69,15 @@ for (const [prefix, count] of [
failure: unpaired,
},
{ name: "count only", expectation: { [count]: 0 }, failure: unpaired },
{
name: "null prefix",
expectation: { [prefix]: null, [count]: 0 },
failure: invalid,
},
{
name: "numeric prefix",
expectation: { [prefix]: 1, [count]: 0 },
failure: invalid,
},
{
name: "array prefix",
expectation: { [prefix]: [], [count]: 0 },
failure: invalid,
},
{
name: "null count",
expectation: { [prefix]: "fixture_", [count]: null },
failure: invalid,
},
{
name: "negative count",
expectation: { [prefix]: "fixture_", [count]: -1 },
failure: invalid,
},
{
name: "fractional count",
expectation: { [prefix]: "fixture_", [count]: 0.5 },
failure: invalid,
},
{
name: "string count",
expectation: { [prefix]: "fixture_", [count]: "0" },
failure: invalid,
},
{
name: "nonfinite count",
expectation: { [prefix]: "fixture_", [count]: Infinity },
failure: invalid,
},
{
name: "unsafe count",
expectation: {
[prefix]: "fixture_",
[count]: Number.MAX_SAFE_INTEGER + 1,
},
failure: invalid,
},
invalidPair("null prefix", null, 0),
invalidPair("numeric prefix", 1, 0),
invalidPair("array prefix", [], 0),
invalidPair("null count", "fixture_", null),
invalidPair("negative count", "fixture_", -1),
invalidPair("fractional count", "fixture_", 0.5),
invalidPair("string count", "fixture_", "0"),
invalidPair("nonfinite count", "fixture_", Infinity),
invalidPair("unsafe count", "fixture_", Number.MAX_SAFE_INTEGER + 1),
])(`validates ${prefix}/${count}: $name`, ({ expectation, failure }) => {
const manifest = {
schemaVersion: 2,