정답인식 기본값: 띄어쓰기 무시(숫자·특수문자는 그대로 켬, 대소문자는 늘 무시). 기본값 회귀 테스트, docs 04·12·13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-04 21:27:19 +09:00
parent 9bc9c4afd5
commit c727abf550
7 changed files with 25 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, test } from 'bun:test';
import { artistCandidates, chosung, hintText, isCorrect, titleCandidates, type Strictness } from './answer';
import { DEFAULT_ROOM_CONFIG } from './room-config';
const STRICT: Strictness = { space: true, number: true, symbol: true };
const LOOSE: Strictness = { space: false, number: false, symbol: false };
@@ -42,6 +43,20 @@ describe('정답인식 toggles (docs/12 Q2): on = must match, off = ignored', ()
expect(isCorrect('시간이 모자라', song('24시간이 모자라'), 'title', STRICT)).toBe(false);
expect(isCorrect('시간이 모자라', song('24시간이 모자라'), 'title', st({ number: false }))).toBe(true);
});
test('새 방 기본값: 띄어쓰기·대소문자 무시, 숫자·특수문자는 쳐야 정답', () => {
const d = DEFAULT_ROOM_CONFIG.strict;
expect(d).toEqual({ space: false, number: true, symbol: true });
expect(isCorrect('사건의지평선', song('사건의 지평선'), 'title', d)).toBe(true);
expect(isCorrect('사 건의지평선', song('사건의 지평선'), 'title', d)).toBe(true);
expect(isCorrect('yoursong', song('Your Song'), 'title', d)).toBe(true);
expect(isCorrect('YOUR SONG', song('Your Song'), 'title', d)).toBe(true);
expect(isCorrect('love', song('Love?'), 'title', d)).toBe(false);
expect(isCorrect('LOVE?', song('Love?'), 'title', d)).toBe(true);
expect(isCorrect('1111', song('11:11'), 'title', d)).toBe(false);
expect(isCorrect('11:11', song('11:11'), 'title', d)).toBe(true);
expect(isCorrect('시간이 모자라', song('24시간이 모자라'), 'title', d)).toBe(false);
expect(isCorrect('24시간이모자라', song('24시간이 모자라'), 'title', d)).toBe(true);
});
test('no fuzzy matching', () => {
expect(isCorrect('사건의 지평산', song('사건의 지평선'), 'title', LOOSE)).toBe(false);
expect(isCorrect('사건의', song('사건의 지평선'), 'title', LOOSE)).toBe(false);

View File

@@ -46,7 +46,7 @@ export interface RoomConfig {
/** Exactly this level (docs/12 Q7). */
level: number;
answer: 'title' | 'artist' | 'both';
/** 정답인식: true = must match that element too (docs/12 Q2). */
/** 정답인식: true = must match that element too (docs/12 Q2). Default: spaces ignored, digits and symbols must match. */
strict: { space: boolean; number: boolean; symbol: boolean };
/** 'none' | seconds | 'manual' (직접선택). */
hint: 'none' | (typeof HINT_TIMES)[number] | 'manual';
@@ -79,7 +79,7 @@ export const DEFAULT_ROOM_CONFIG: RoomConfig = {
yearTo: null,
level: 3,
answer: 'title',
strict: { space: true, number: true, symbol: true },
strict: { space: false, number: true, symbol: true },
hint: 'none',
hintVotes: '1/3',
skipVotes: '1/3',