import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import { createHash } from 'node:crypto'; import path from 'node:path'; import { susScoreWeight } from './sus-score-weight.mjs'; const record = JSON.parse(await readFile(new URL('../docs/research/sus-score-formulas.json', import.meta.url), 'utf8')); const directory = process.argv[2] ?? 'data/raw/sus'; for (const row of [...record.validationCharts, ...record.charts]) { const bytes = await readFile(path.join(directory, `chart_${row.songId}_${row.difficulty}.sus`)); assert.equal(createHash('sha256').update(bytes).digest('hex'), row.susSha256); const actual = susScoreWeight(bytes.toString('utf8')); assert.equal(actual.songId, row.songId); assert.equal(actual.perfectNoteWeight, row.perfectNoteWeight, `${row.songId}.${row.difficulty}`); if (row.counts) { assert.deepEqual(actual.counts, row.counts); assert.equal(actual.invisibleRelayCount, row.invisibleRelayCount); assert.equal(actual.bezierPointCount, row.bezierPointCount); } } console.log(`${record.validationCharts.length}개 기존 분모와 ${record.charts.length}개 신규 SUS 분모를 재현했습니다.`);