MCPcopy Create free account
hub / github.com/SethGammon/Citadel / test

Function test

scripts/test-organize-enforce.js:97–115  ·  view source on GitHub ↗
(name, fn)

Source from the content-addressed store, hash-verified

95let currentSandbox = null;
96
97function test(name, fn) {
98 const start = Date.now();
99 let passed = false;
100 let detail = '';
101 currentSandbox = sandbox();
102 try {
103 const result = fn(currentSandbox);
104 passed = result === true || result === undefined;
105 if (typeof result === 'string') { passed = false; detail = result; }
106 } catch (e) {
107 detail = e.message;
108 }
109 cleanup(currentSandbox);
110 const ms = Date.now() - start;
111 results.push({ name, passed, detail, ms });
112 const icon = passed ? 'PASS' : 'FAIL';
113 const suffix = detail ? `\n ${detail}` : '';
114 console.log(` ${icon} ${name} (${ms}ms)${suffix}`);
115}
116
117// ── Tests ────────────────────────────────────────────────────────────────────
118

Callers 1

Calls 2

sandboxFunction · 0.70
cleanupFunction · 0.70

Tested by

no test coverage detected