MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / assertParity

Function assertParity

__tests__/kernel-ccpp-parity.test.ts:78–96  ·  view source on GitHub ↗
(filePath: string, source: string, language: Language, minNodes = 3)

Source from the content-addressed store, hash-verified

76 });
77
78 function assertParity(filePath: string, source: string, language: Language, minNodes = 3): void {
79 process.env.CODEGRAPH_KERNEL_LANGS = 'all';
80 delete process.env.CODEGRAPH_KERNEL;
81 const viaKernel = tryKernelExtract(filePath, source, language);
82 expect(viaKernel, `kernel extraction failed for ${filePath}`).not.toBeNull();
83
84 process.env.CODEGRAPH_KERNEL = '0';
85 const viaWasm = extractFromSource(filePath, source, language);
86 delete process.env.CODEGRAPH_KERNEL;
87
88 const k = canon(viaKernel!);
89 const w = canon(viaWasm);
90 expect(k.nodes, `${filePath}: nodes`).toEqual(w.nodes);
91 expect(k.edges, `${filePath}: edges`).toEqual(w.edges);
92 expect(k.refs, `${filePath}: refs`).toEqual(w.refs);
93 // Meaningful comparison, not empty-vs-empty (the inline Metal/CUDA
94 // sources are deliberately small — they pass their exact node count).
95 expect(viaWasm.nodes.length).toBeGreaterThanOrEqual(minNodes);
96 }
97
98 it('torture fixture (c): fn-ptr tables, typedefs, file-scope consts, value-refs', () => {
99 const file = path.join(FIXTURE_DIR, 'torture.c');

Callers 1

Calls 3

tryKernelExtractFunction · 0.90
extractFromSourceFunction · 0.90
canonFunction · 0.70

Tested by

no test coverage detected