Snapshot differential tests (known deviations registered, current state passes): - title/path recognition: 216 samples vs MP MetaInfo/MetaInfoPath - filter rules: 42 rules x 28 torrents vs MP FilterModule - RSS/indexer parsing: 15 feeds, 72 indexer samples - zhconv: 69 samples Generator: scripts/mp-sync/gen-differential.py; report: docs/porting/mp-rust-logic-parity.md Co-Authored-By: Claude Opus 5.5 <[email protected]>
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
/**
|
|
* 繁→简差分:MP moviepilot_rust.zhconv_fast(zh-hans) vs identity/toSimplified。
|
|
* 期望由 `scripts/mp-sync/gen-differential.py zhconv` 生成;已知差异登记在 zhconv-deviations.json。
|
|
*/
|
|
import { readFileSync } from "node:fs";
|
|
import { expect, it } from "vitest";
|
|
import { toSimplified } from "../../src/identity/index.ts";
|
|
|
|
const read = (n: string) => JSON.parse(readFileSync(new URL(`./${n}`, import.meta.url), "utf8"));
|
|
const mp: Record<string, string> = read("zhconv-mp.json").hans;
|
|
const dev: Record<string, { mp: string; ours: string }> = read("zhconv-deviations.json").deviations;
|
|
|
|
it("toSimplified 与 MP zhconv 的差异集合 == 登记集合", () => {
|
|
const actual: Record<string, { mp: string; ours: string }> = {};
|
|
for (const [src, want] of Object.entries(mp)) {
|
|
const ours = toSimplified(src);
|
|
if (ours !== want) actual[src] = { mp: want, ours };
|
|
}
|
|
const snapshot = Object.fromEntries(Object.entries(dev).map(([k, d]) => [k, { mp: d.mp, ours: d.ours }]));
|
|
expect(actual).toEqual(snapshot);
|
|
expect(Object.keys(mp).length).toBeGreaterThanOrEqual(60);
|
|
});
|