MCPcopy Create free account
hub / github.com/denoland/std / runConformanceTests

Function runConformanceTests

http/unstable_structured_fields_test.ts:903–1020  ·  view source on GitHub ↗
(
  t: Deno.TestContext,
  filename: string,
)

Source from the content-addressed store, hash-verified

901
902// Load and run tests from a JSON file
903async function runConformanceTests(
904 t: Deno.TestContext,
905 filename: string,
906): Promise<void> {
907 const testData = await import(`./testdata/structured_fields/${filename}`, {
908 with: { type: "json" },
909 });
910 const tests: ConformanceTestCase[] = testData.default;
911
912 for (const test of tests) {
913 // Skip tests marked can_fail (implementation-dependent)
914 if (test.can_fail) continue;
915
916 const rawInput = test.raw.join(", ");
917 const headerType = test.header_type ?? "item";
918
919 await t.step(test.name, () => {
920 if (test.must_fail) {
921 // Test should fail parsing
922 assertThrows(
923 () => {
924 switch (headerType) {
925 case "item":
926 parseItem(rawInput);
927 break;
928 case "list":
929 parseList(rawInput);
930 break;
931 case "dictionary":
932 parseDictionary(rawInput);
933 break;
934 }
935 },
936 Error,
937 );
938 } else {
939 // Test should succeed
940 switch (headerType) {
941 case "item": {
942 const parsed = parseItem(rawInput);
943 const expected = convertExpectedItem(test.expected);
944 assertEquals(
945 itemsEqual(parsed, expected),
946 true,
947 `Mismatch for "${test.name}": got ${
948 JSON.stringify(parsed)
949 }, expected ${JSON.stringify(expected)}`,
950 );
951 // Test canonical serialization if provided
952 if (test.canonical) {
953 const serialized = serializeItem(parsed);
954 assertEquals(serialized, test.canonical[0]);
955 }
956 break;
957 }
958 case "list": {
959 const parsed = parseList(rawInput);
960 const expected: List = test.expected.map(

Callers 1

fnFunction · 0.85

Calls 15

assertThrowsFunction · 0.90
parseItemFunction · 0.90
parseListFunction · 0.90
parseDictionaryFunction · 0.90
assertEqualsFunction · 0.90
serializeItemFunction · 0.90
serializeListFunction · 0.90
serializeDictionaryFunction · 0.90
convertExpectedItemFunction · 0.85
itemsEqualFunction · 0.85
listMembersEqualFunction · 0.85

Tested by

no test coverage detected