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

Function inCfgTestModule

src/graph/test-code.ts:119–144  ·  view source on GitHub ↗
(source: string, line: number)

Source from the content-addressed store, hash-verified

117 * needs to go.
118 */
119export function inCfgTestModule(source: string, line: number): boolean {
120 const lines = blankRustCode(source).split('\n');
121 let armed = false;
122 for (let i = 0; i < lines.length && i < line; i++) {
123 const text = lines[i]!.trim();
124 if (CFG_TEST.test(text)) { armed = true; continue; }
125 if (!armed) continue;
126 if (text.startsWith('#[') || text === '') continue;
127 armed = false;
128 if (!/^(?:pub(?:\([^)]*\))?\s+)?mod\s+\w+\s*\{/.test(text)) continue;
129 // Walk the block: it ends on the line where its braces close.
130 let depth = 0;
131 for (let j = i; j < lines.length; j++) {
132 for (const ch of lines[j]!) {
133 if (ch === '{') depth++;
134 else if (ch === '}') depth--;
135 }
136 if (depth <= 0) {
137 if (line - 1 > i && line - 1 <= j) return true;
138 i = j;
139 break;
140 }
141 }
142 }
143 return false;
144}

Callers 2

isTestCodeFunction · 0.85

Calls 1

blankRustCodeFunction · 0.90

Tested by

no test coverage detected