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

Function inCfgTestModule

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

Source from the content-addressed store, hash-verified

87 * needs to go.
88 */
89export function inCfgTestModule(source: string, line: number): boolean {
90 const lines = blankRustCode(source).split('\n');
91 let armed = false;
92 for (let i = 0; i < lines.length && i < line; i++) {
93 const text = lines[i]!.trim();
94 if (CFG_TEST.test(text)) { armed = true; continue; }
95 if (!armed) continue;
96 if (text.startsWith('#[') || text === '') continue;
97 armed = false;
98 if (!/^(?:pub(?:\([^)]*\))?\s+)?mod\s+\w+\s*\{/.test(text)) continue;
99 // Walk the block: it ends on the line where its braces close.
100 let depth = 0;
101 for (let j = i; j < lines.length; j++) {
102 for (const ch of lines[j]!) {
103 if (ch === '{') depth++;
104 else if (ch === '}') depth--;
105 }
106 if (depth <= 0) {
107 if (line - 1 > i && line - 1 <= j) return true;
108 i = j;
109 break;
110 }
111 }
112 }
113 return false;
114}

Callers 2

isTestCodeFunction · 0.85

Calls 1

blankRustCodeFunction · 0.90

Tested by

no test coverage detected