mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 18:55:22 +00:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { DEFAULT_CONFIG, normalizeConfig } from "../src/config.ts";
|
|
|
|
test("normalizes one greenfield piCompaction config without legacy aliases", () => {
|
|
const config = normalizeConfig({
|
|
enabled: false,
|
|
softRatio: 0.7,
|
|
hardRatio: 0.91,
|
|
targetRatio: 0.5,
|
|
deterministic: { enabled: false, maxStubTokens: 512 },
|
|
semantic: { enabled: false, concurrency: 2, maxRetries: 0 },
|
|
native: { enabled: false },
|
|
});
|
|
assert.equal(config.enabled, false);
|
|
assert.equal(config.deterministic.enabled, false);
|
|
assert.equal(config.deterministic.maxStubTokens, 512);
|
|
assert.equal(config.semantic.enabled, false);
|
|
assert.equal(config.semantic.maxRetries, 0);
|
|
assert.equal(config.native.enabled, false);
|
|
});
|
|
|
|
test("invalid ratios and bounds fail safe to bounded defaults", () => {
|
|
const config = normalizeConfig({
|
|
softRatio: 2,
|
|
hardRatio: -1,
|
|
targetRatio: 0.99,
|
|
semantic: { concurrency: 50, maxRetries: -1 },
|
|
});
|
|
assert.equal(config.softRatio, DEFAULT_CONFIG.softRatio);
|
|
assert.ok(config.targetRatio < config.softRatio);
|
|
assert.ok(config.hardRatio > config.softRatio);
|
|
assert.equal(config.semantic.concurrency, DEFAULT_CONFIG.semantic.concurrency);
|
|
assert.equal(config.semantic.maxRetries, DEFAULT_CONFIG.semantic.maxRetries);
|
|
});
|